Hi, I have a link that says: <%= link_to_remote("Data", :update => ''pie_graph_div'', :url => { :action => :show_pie_graph, :mode => ''nums'' }) %> which calls *show_pie_graph*: Controller: def show_pie_graph render :layout => false @mode = params[:mode] end View: <img src="/surveys/make_pie_graph/<%=@mode%>" /> But @mode on view always is nil. I can see the :mode from the view by calling params[:mode] but not from the controller. What''s the problem? Did I misunderstand something? Thanks in advance, - H
Human Dunnil wrote:> Controller: > def show_pie_graph > render :layout => false > @mode = params[:mode] > end > View: > <img src="/surveys/make_pie_graph/<%=@mode%>" /> > > But @mode on view always is nil. > I can see the :mode from the view by calling params[:mode] but not > from the controller.Set @mode before calling render. -- We develop, watch us RoR, in numbers too big to ignore.
Thanks On 1/31/06, Mark Reginald James <mrj@bigpond.net.au> wrote:> Human Dunnil wrote: > > > Controller: > > def show_pie_graph > > render :layout => false > > @mode = params[:mode] > > end > > View: > > <img src="/surveys/make_pie_graph/<%=@mode%>" /> > > > > But @mode on view always is nil. > > I can see the :mode from the view by calling params[:mode] but not > > from the controller. > > Set @mode before calling render. > > > -- > We develop, watch us RoR, in numbers too big to ignore. > > _______________________________________________ > Rails mailing list > Rails@lists.rubyonrails.org > http://lists.rubyonrails.org/mailman/listinfo/rails >
You need to swap the lines in the controller. def show_pie_graph @mode = params[:mode] render :layout => false end The ''render'' method uses the current state of the controller at the time it is called to setup the view. At that time, @mode is not yet set, so that is what the view sees. -----Original Message----- From: rails-bounces@lists.rubyonrails.org [mailto:rails-bounces@lists.rubyonrails.org] On Behalf Of Human Dunnil Sent: Monday, January 30, 2006 1:58 PM To: rails@lists.rubyonrails.org Subject: [Rails] params on controller and view Hi, I have a link that says: <%= link_to_remote("Data", :update => ''pie_graph_div'', :url => { :action => :show_pie_graph, :mode => ''nums'' }) %> which calls *show_pie_graph*: Controller: def show_pie_graph render :layout => false @mode = params[:mode] end View: <img src="/surveys/make_pie_graph/<%=@mode%>" /> But @mode on view always is nil. I can see the :mode from the view by calling params[:mode] but not from the controller. What''s the problem? Did I misunderstand something? Thanks in advance, - H _______________________________________________ Rails mailing list Rails@lists.rubyonrails.org http://lists.rubyonrails.org/mailman/listinfo/rails