Pradeep Sethi
2006-May-02 04:41 UTC
[Rails] passing data from controller to rjs and then to partial
Hello Experts, I am fetching data in my controller from a web service def search response = @@api.DoSearch() end and in my .rjs template, I am doing page.replace_html ''fields_chooser'', :partial => ''fields_chooser'' ,:locals =>{:response => response} page.visual_effect(:Appear, ''fields_chooser'') and in _fields_chooser.rhtml, I want to use response. But I can''t see response in my .rhtml file. what am I missing here? how do I pass data "response" from controller to the .rhtml file or should I be doing this in a different way? Thanks guys for any help. PS -- Posted via http://www.ruby-forum.com/.
Liquid
2006-May-02 04:50 UTC
[Rails] passing data from controller to rjs and then to partial
The response variable that you have set response = @@api.DoSearch() is only local scope. When you enter your rjs, it has gone out of scope. Use @response = @@api.DoSearch() and in the rjs page.replace_html ''fields_chooser'', :partial => ''fields_chooser'' ,:locals =>{:response => @response} page.visual_effect(:Appear, ''fields_chooser'') I think this should fix it. On 5/2/06, Pradeep Sethi <psethi@gmail.com> wrote:> > Hello Experts, > > I am fetching data in my controller from a web service > > def search > response = @@api.DoSearch() > end > > and in my .rjs template, I am doing > > page.replace_html ''fields_chooser'', :partial => ''fields_chooser'' > ,:locals =>{:response => response} > page.visual_effect(:Appear, ''fields_chooser'') > > and in _fields_chooser.rhtml, I want to use response. But I can''t see > response in my .rhtml file. > > what am I missing here? how do I pass data "response" from controller to > the .rhtml file or should I be doing this in a different way? > > Thanks guys for any help. > > > PS > > -- > Posted via http://www.ruby-forum.com/. > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >-------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060502/fc85812d/attachment.html
Steve Ross
2006-May-02 05:39 UTC
[Rails] Re: passing data from controller to rjs and then to partial
Did you mean @response instead of "response"? Pradeep Sethi wrote:> Hello Experts, > > I am fetching data in my controller from a web service > > def search > response = @@api.DoSearch() > end ><trim> -- Posted via http://www.ruby-forum.com/.
Pradeep Sethi
2006-May-02 06:05 UTC
[Rails] Re: passing data from controller to rjs and then to partial
Hi, I am actually using response. strangely, If I do @response = @@api.DoSearch() I get this error: undefined method `body='' for #<Array:0x36accd0> Stack trace below: however, if I just use response, I can see the response fine in logger, but I am not able to pass the response to the rjs template. I am a NewB, so apologize if am not very clear. Your help is greatly appreciated. thanks, c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:746:in `erase_render_results'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:764:in `erase_results'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/rescue.rb:28:in `rescue_action'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/rescue.rb:108:in `perform_action'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:in `send'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/base.rb:379:in `process_without_filters'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/filters.rb:364:in `process_without_session_management_support'' c:/ruby/lib/ruby/gems/1.8/gems/actionpack-1.12.0/lib/action_controller/session_management.rb:117:in `process'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/dispatcher.rb:38:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:115:in `handle_dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:81:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'' c:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'' c:/ruby/lib/ruby/1.8/webrick/server.rb:155:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:144:in `start_thread'' c:/ruby/lib/ruby/1.8/webrick/server.rb:94:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `each'' c:/ruby/lib/ruby/1.8/webrick/server.rb:89:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' c:/ruby/lib/ruby/1.8/webrick/server.rb:79:in `start'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/webrick_server.rb:67:in `dispatch'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/servers/webrick.rb:59 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/rails-1.1.0/lib/commands/server.rb:30 c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require__'' c:/ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:21:in `require'' c:/ruby/lib/ruby/gems/1.8/gems/activesupport-1.3.0/lib/active_support/dependencies.rb:136:in `require'' script/server:3 Steve Ross wrote:> Did you mean @response instead of "response"? > > Pradeep Sethi wrote: >> Hello Experts, >> >> I am fetching data in my controller from a web service >> >> def search >> response = @@api.DoSearch() >> end >> > <trim>-- Posted via http://www.ruby-forum.com/.
Jeff Coleman
2006-May-02 10:24 UTC
[Rails] Re: passing data from controller to rjs and then to partial
Pradeep Sethi wrote:> Hello Experts, > > I am fetching data in my controller from a web service > > def search > response = @@api.DoSearch() > end > > and in my .rjs template, I am doing > > page.replace_html ''fields_chooser'', :partial => ''fields_chooser'' > ,:locals =>{:response => response} > page.visual_effect(:Appear, ''fields_chooser'')I haven''t been able to get the :locals parameter to work in an RJS call either, so what I''ve done in cases like this is to use an instance variable. @response is a reserved attribute so you might try a different variable name in such a case. Jeff -- Posted via http://www.ruby-forum.com/.