I''m not sure what happened, or what change has caused this to happen, but render :partial (or any render for that matter, doesn''t seem to let me set local variables via the local_assigns argument hash. for example <%= render :partial ''edit'', :username => @user.username %> used to allow that username was a local variable in my _edit.rhtml partial template. example: <p><b>Username:</b> <%= username %></p> Could this be a problem with Ruby 1.8.4? -- Sean Wolfe master nerd of i heart squares, Co. 3711 N. Ravenswood Ave. #147 Chicago, IL 60613 Ph. (773) 531-6301 Fx. (773) 529-7041 http://www.iheartsquares.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060103/5feaf484/attachment.html
Sean Wolfe
2006-Jan-03 21:50 UTC
[Rails] Re: render :partial stops setting local variables.
On 1/3/06, Sean Wolfe <sean@iheartsquares.com> wrote:> > > Could this be a problem with Ruby 1.8.4? >Tried it on Ruby 1.8.2 and it still fails... Is there soem sort of environment setting that controls how varaibles get passed in the render method? This used to work fine, yestrday, but suddenly today, on all my machines this stopped working. Any help or insight would be greatly appreciated. -- Sean Wolfe master nerd of i heart squares, Co. 3711 N. Ravenswood Ave. #147 Chicago, IL 60613 Ph. (773) 531-6301 Fx. (773) 529-7041 http://www.iheartsquares.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060103/20c68591/attachment.html
On 1/3/06, Sean Wolfe <sean@iheartsquares.com> wrote:> I''m not sure what happened, or what change has caused this to happen, but > render :partial (or any render for that matter, doesn''t seem to let me set > local variables via the local_assigns argument hash. > > for example > > <%= render :partial ''edit'', :username => @user.username %>I believe you want: <%= render :partial ''edit'', :locals => {:username => @user.username} %>
On 1/3/06, Lance Ball <lanceball@gmail.com> wrote:> On 1/3/06, Sean Wolfe <sean@iheartsquares.com> wrote: > > I''m not sure what happened, or what change has caused this to happen, > but > > render :partial (or any render for that matter, doesn''t seem to let me > set > > local variables via the local_assigns argument hash. > > > > for example > > > > <%= render :partial ''edit'', :username => @user.username %> > > I believe you want: > > <%= render :partial ''edit'', :locals => {:username => @user.username} %>Ahhh thanks.. Thats it! I take it that api.rubyonrails.com isn''t up to date. http://api.rubyonrails.com/classes/ActionView/Base.html#M000468 show this still *render*(options = {}, old_local_assigns = {}) I also tried the previous way containing the two hash arguments in curly braces, it still ignored the local assigns. I just wonder why this was working fine before, and then suddenly stopped working? -- Sean Wolfe master nerd of i heart squares, Co. 3711 N. Ravenswood Ave. #147 Chicago, IL 60613 Ph. (773) 531-6301 Fx. (773) 529-7041 http://www.iheartsquares.com -------------- next part -------------- An HTML attachment was scrubbed... URL: http://wrath.rubyonrails.org/pipermail/rails/attachments/20060104/6a484cbc/attachment-0001.html