Reputation: 149
For a single object I was able to make it generic by doing f.object
<%= render 'shared/error_messages', object: f.object %>
which allowed my make my partial generic
<% if object.errors.any? %>
how would i do a similar thing for any array, like these
<%= render partial: 'shared/feed_item', collection: @feed_items %>
<%= render partial: 'shared/feed_item', collection: @all_items %>
so that in the partial i could reference it with my_item and not feed_item ?
<li id="<%= feed_item.id %>">
Upvotes: 1
Views: 180
Reputation: 21884
<%= render partial: 'shared/feed_item', collection: @feed_items, as: :feed_item %>
<%= render partial: 'shared/feed_item', collection: @all_items, as: :feed_item %>
Upvotes: 1