I have an app which shows mugs (for drinking), each mug can have many photos.
The mugs are displayed as partials on the index page and when clicked the user gets taken to the mugs show page and they can see all the photos added.
How can I go about using one of the photos to display on the mugs partial? I'm thinking either the first uploaded or a way of selecting an uploaded photo to be used on the partial.
mug show.html.erb
<% if @mug.mugphotos.count.zero? %>
<div class="no_photos">
None added yet.
</div>
<% else %>
<% for mugphoto in @mug.mugphotos %>
<%= link_to image_tag(mugphoto.mugphoto.url(:thumb), :class => "mug_photo"), mugphoto.mugphoto.url(:large) %>
<% end %>
<% end %>
mug partial
<%= link_to mug do %>
<div class="mug_partial">
<div class="mug_partial_photo">
</div>
<span class="mug_partial_name"><%= mug.name %></span>
</div>
<% end %>
Thanks for any help.