html - how to add inline css to rails link_to helper -
am on rails 5 , categories have images. want use images backround images when set in styling url not change
<div class="grid-category"> <% @servicescategories.each |category| %> <%= link_to servicecategories_path(slug: category.slug ), :style=>'background-image: asset-data-url("category.category_image");', class: "category-item" %> <h3> <%= category.name %></h3> <% end %> <% end %> </div>
what doing wrong here
you need interpolate value of category.category_image
<%= link_to servicecategories_path(slug: category.slug ), class: "category-item" %> <div style="background-image: url(<%= asset_path('category.category_image') %>)"> <h3> <%= category.name %></h3> </div> <% end %>
Comments
Post a Comment