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

Popular posts from this blog

magento2 - Magento 2 admin grid add filter to collection -

Android volley - avoid multiple requests of the same kind to the server? -

Combining PHP Registration and Login into one class with multiple functions in one PHP file -