Hello.
My rjs cannot obtain the instance variable set up in the associated controller method. I have described the code below. Will appreciate any thoughts on "why". I am using InstantRails on Windows XP with the Rails version of 2.0.2.
I have the following code (simplified)
in LearnController.rb
def page_via_ajax # debugger render :layout => false puts("in LearnController.page_via_ajax method") @my_page_id = "pg_7" end
in page_via_ajax.rjs
puts("in page_via_ajax.rjs") puts("@my_page_id:#{@my_page_id}:")
System output:
in LearnController.page_via_ajax method in page_via_ajax.rjs @my_page_id::
Apparently the rjs file does not get the value of the @my_page_id instance variable created in the controller.
What are the reasons and what is the solution?
With thanks and regards,
Abbas
The render happens when you call render (is this surprising?), and you assign to @my_page_id after you call render.
Fred
Thanks, Fred!
I assumed that "render :layout => false" was a configuration setting which would be used whenever Rails renders and did not realise that the statement would actually render!
With regards, Abbas