私は、背景イメージを持つ複数の項目を表示する索引ビューを持っています。 urlは文字列product.imageです。ここにインデックスビューがあります。索引項目に異なる背景イメージを与える方法
<div class="products">
<% @products.each do |product| %>
<style>
.product-image-index {
background-image: url('<%= product.image %>');
background-size: cover;
background-position: center;
background-repeat: no-repeat;
}
</style>
<div class="product-con">
<div class="product-image-index">
</div>
<div class="product-text">
<div class="title"><%= product.name %></div>
<div class="button-con">
<span class="button"><%= link_to 'More Info', product, class: "buton" %></span>
</div>
</div>
</div>
<% end %>
</div>
問題は、背景画像が同じイメージを持っている、と私は理解しますが、各項目がそれぞれの背景画像を示しているように、この問題を解決するものです。