Render partials: set the name of a collection manually?

Hi all

<%= render :partial => ‘users’, :collection => some_array %>

This automatically assumes the the collection object in the partial is
called user. What if I want it to be called otherwise? Is there a
parameter to specify that?

Thanks
Josh

Joshua M. wrote:

Hi all

<%= render :partial => ‘users’, :collection => some_array %>

This automatically assumes the the collection object in the partial is
called user. What if I want it to be called otherwise? Is there a
parameter to specify that?

Thanks
Josh

I find I get the most control with something like:

<% some_array.each do |foo| %>
<%= render :partial => ‘users’, :locals => {:bar => foo} %>
<% end %>

Thanks. I guess this is the best way, although it makes :collection
quite unusable…

On 27 November 2006 23:09, Joshua M. wrote:

<%= render :partial => ‘users’, :collection => some_array %>

This automatically assumes the the collection object in the partial is
called user. What if I want it to be called otherwise? Is there a
parameter to specify that?
I usually rename variable inside partial like this:

/mycontroller/_some_users.rhtml

<% users = some_users %>
<% for user in users %>

<% end %>