Forum: Ruby on Rails render :partial stops setting local variables.

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Sean W. (Guest)
on 2006-01-03 23:31
(Received via mailing list)
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 W.
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
Sean W. (Guest)
on 2006-01-03 23:53
(Received via mailing list)
On 1/3/06, Sean W. <removed_email_address@domain.invalid> 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 W.
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
Lance B. (Guest)
on 2006-01-03 23:56
(Received via mailing list)
On 1/3/06, Sean W. <removed_email_address@domain.invalid> 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} %>
Sean W. (Guest)
on 2006-01-04 21:06
(Received via mailing list)
On 1/3/06, Lance B. <removed_email_address@domain.invalid> wrote:

>
> 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...
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 W.
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
This topic is locked and can not be replied to.