I'm trying to write an if statement in a table to get one image if an image doesn't exist in the database. Im able to retrieve both images separately but not with the if statement. What am I doing wrong in my code.
<h1>Won Auctions</h1>
<br>
<table class= "table table-hover" >
<thead>
<tr>
<th>Name</th>
<th>Price</th>
<th>End Date</th>
<th>Seller</th>
<th colspan="3"></th>
</tr>
</thead>
<tbody>
<% won.each do |a| %>
<tr>
<td><%=
if a.image.exists? %>
<% image_tag(a.image, width:100) %>
else
<% image_tag("No_image.jpg", width:100) %>
<% end %>
%><td>
<td><%= a.name %></td>
<td><%= number_to_currency(a.highest_bid) %></td>
<td><%= a.auction_end_time %></td>
<td><%= a.seller.email %></td>
</tr>
<% end %>
</tbody>
</table>
<br>
Aucun commentaire:
Enregistrer un commentaire