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
Did you mean @response instead of “response”?
Pradeep S. wrote:
Hello Experts,
I am fetching data in my controller from a web service
def search
response = @@api.DoSearch()
end
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 R. wrote:
Did you mean @response instead of “response”?
Pradeep S. wrote:
Hello Experts,
I am fetching data in my controller from a web service
def search
response = @@api.DoSearch()
end
Pradeep S. 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
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.