Render :collection and :partial

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.

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.

Rendering collections is only meant to be done with partials.


http://www.5valleys.com/
http://www.workingwithrails.com/person/8078

: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.