Adding an image_tag for the inline background-image url in Rails 5 template
问题 I need to set the background image inline using the style tag, but it needs to reference an image object and not a fixed image from the assets folder. Below is my code to show what I am attempting to do. <div class="background-image-holder" style="background: url(#{" image_path @product.photo_one_url(:original)"}); opacity: 1;"> <%= image_tag(@product.photo_one_url(:medium)) %> </div> 回答1: I always prefer to use a content_tag if I'm including something dynamic like this, i.e. <%= content_tag