views:

62

answers:

1

I have successfully followed Ryan Bates tutorial of paperclip and have it working correctly. The image attaches to the record and displays on the show.html.erb.I am wondering how to display it on the index pages. Below is what I have tried but not working. For reference, the table is 'review' and the photo is 'photo'.

<table>
  <tr>
    <th>Photo</th>
    <th>Review Title</th>
    <th>Content</th>
    <th>Name</th>
    <th>Job Title</th>
    <th>Company</th>
  </tr>

<% @reviews.each do |review| %>
  <tr>
    <td><%=h review.photo.url %></td>
    <td><%=h review.review_title %></td>
    <td><%=h review.content %></td>
    <td><%=h review.name %></td>
    <td><%=h review.position %></td>
    <td><%=h review.company %></td>
    <td><%= link_to 'Show', review %></td>
    <td><%= link_to 'Edit', edit_review_path(review) %></td>
    <td><%= link_to 'Destroy', review, :confirm => 'Are you sure?', :method => :delete %></td>
  </tr>
<% end %>
</table>
+2  A: 

You'll want to use the image_tag helper:

<td><%= image_tag review.photo.url %></td>
Garrett