Question

I want to render some child items with something other than their default partial (i.e., app/views/child_items/_child_item.html.erb). The default one was scaffolded and it isn't great for public viewing of something, but I still want to keep it for back-end management purposes.

This is what I'm going for inside the view of the parent item, assuming a partial defined in app/views/child_items/_alternate_partial.html.erb:

<%= render containing_object.child_items, :partial => 'child_items/alternate_partial' %>

But the child items still render with their default partial.

Was it helpful?

Solution

Try this one:

<%= render 'child_items/alternate_partial', :collection => containing_object.child_items %>
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top