我在hmtl.erb文件中工作,尝试将图像源作为产品对象参数保存的链接。
<% @products.each do |categories,products| %>
<% products.each do |product| %>
<div class="container">
<div class="row">
<div class="col-sm-4">
<div class="panel panel-primary">
<div class="panel-heading">
<%= link_to product.name, product_path(product.permalink) %></div>
<%-# the image source link below is not working -%>
<div class="panel-body"><img src= product.default_image.path class="img-responsive" style="height: 250 width:250" alt="Image"></div>
<div class="panel-footer"><%= product.short_description %></div>
</div>
</div>
</div>
</div><br>
<%end%>
我已尝试将其放在引号中并执行@ product.default_image.path。我没有尝试过的任何作品
答案 0 :(得分:0)
使用rails helper image_tag
<div class="panel-body">
<%= image_tag(product.default_image.path, class: 'img-responsive') %>
</div>