html - How to add a specific item's image as a background image in rails -


this 1 frustrating me. i'm using paperclip images, , adding them model offer that's fine. problem adding them in background image on index page offer code looks this:

<div class="product-image"></div> <style> .product-image {      width: 50%;      height: 200px;      margin-left: 25%;      border-radius: 50%;      background-image: url(<%= image_tag offer.image %>);      background-size: cover;      background-repeat: no-repeat;      background-position: center; } </style> 

when inspect on chrome, code looks this:

background-image: url(<img src="/system/offers/images/000/000/033/original/headphones.jpg?1468610654" alt="headphones" />); 

anybody know fix? said, images working fine. if put line of code in <%= image_tag offer.image %>, image shows. appreciated.

you using image_tag helper creates html tag

you should use asset_url helper

asset_url('url image in asset folder') 

if choose declare on css file (in stylesheet assets) dont forget rename scss.


Comments

Popular posts from this blog

javascript - Slick Slider width recalculation -

jsf - PrimeFaces Datatable - What is f:facet actually doing? -

angular2 services - Angular 2 RC 4 Http post not firing -