Does the :collection option on render only work with :partials? Or can I call render :collection directly from a controller against a normal (non-partial) template? I couldn''t get it to work but maybe I am missing something. --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pito wrote:> Does the :collection option on render only work with :partials? Or can > I call render :collection directly from a controller against a normal > (non-partial) template? I couldn''t get it to work but maybe I am > missing something. >Rendering collections is only meant to be done with partials. -- http://www.5valleys.com/ http://www.workingwithrails.com/person/8078 --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
Pito, we''d need to see some code to be more helpful. Try changing the name of the partial to match the model / variable names. Pito wrote:> Does the :collection option on render only work with :partials? Or can > I call render :collection directly from a controller against a normal > (non-partial) template? I couldn''t get it to work but maybe I am > missing something.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
:collection only works on partials in this instance. You can streamline your render partial calls by using instance variable names that match your class and partial name e.g. <%= render :partial => @posts %> would render the collection @posts in a partial called _post.html.erb (Rails 2.0.2) ( i think) If you wanted to render a colleciton in a normal template either create the partial call within it or use the each method to iterate the collection. e.g. @posts.each do |post| .... end With more AJAX stuff it makes sense to use partials more often so you can reload sections of your view easily from rjs. On Mar 4, 11:29 pm, tshim <humanorien...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> Pito, we''d need to see some code to be more helpful. > > Try changing the name of the partial to match the model / variable > names. > > Pito wrote: > > Does the :collection option on render only work with :partials? Or can > > I call render :collection directly from a controller against a normal > > (non-partial) template? I couldn''t get it to work but maybe I am > > missing something.--~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---