I have the following listing:
<% @backgrounds.each do |background| %>
<tr>
<td><%= background.image.url %></td>
<td><%= link_to 'Show', background %></td>
<td><%= link_to 'Edit', edit_background_path(background) %></td>
</tr>
<% end %>
I am trying to reuse this with other controllers. This is what I have so far:
<%= render partial:'image_listing', locals:{images:@backgrounds} %>
<% images.each do |image| %>
<tr>
<td><%= image.image.url %></td>
<td><%= link_to 'Show', image %></td>
<td><%= link_to 'Edit', edit_image_path(image) %></td>
</tr>
<% end %>
Is there a more generic version of edit_image_path?
If you call the partial with the same name of the object you want to iterate, the shortest form is
If you can’t follow this convention, use
:collectionand:partialoptions to instruct the rendering.See
ActionView::Partials.