Joshua Muheim
2006-Nov-27 20:09 UTC
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 -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Alex Wayne
2006-Nov-28 08:06 UTC
Re: render partials: set the name of a collection manually?
Joshua Muheim 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 > JoshI find I get the most control with something like: <% some_array.each do |foo| %> <%= render :partial => ''users'', :locals => {:bar => foo} %> <% end %> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Joshua Muheim
2006-Nov-28 09:34 UTC
Re: render partials: set the name of a collection manually?
Thanks. I guess this is the best way, although it makes :collection quite unusable... -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---
Maxim Kulkin
2006-Nov-28 09:46 UTC
Re: render partials: set the name of a collection manually?
On 27 November 2006 23:09, Joshua Muheim 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 %> --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---