Lets say I have a wine and beer model/controller along with a wine_review and beer_review model with a has many relationship.
Each table has near identical data types, for example, wine_review and beer_review each has a rating and comment column. Wine and beer each, have names.
How can I dry up my code so they can both share the same views.
Right now I have two views doing the same thing, once for beer and once for wine.
<% @wine_reviews.each do |review| -%>
<ul>
<li><%= link_to review.wine.name, review.wine %></li>
<li><%= review.rating %></li>
<li><%=h review.comment %></li>
</ul>
<% end -%>
<% @beer_reviews.each do |review| -%>
<ul>
....
....
What I would really like to do is something like
<li><%= link_to review.beverage.name, review.beverage %></li>
Where beverage would be replaced with wine or beer depending on what I'm rendering at that time but I can't figure out how to do that.
I can't pass beverage as a local to a partial as review.beverge will break.
Thanks.