Yalın Semer Yalın Semer - 1 year ago 64
Ruby Question

How to reference image in data attribute within Rails 5

i'm new on Rails. I can use images with


But , i have an html template and these methods does not work in data-attributes. In my html , there is a
attribute which changes background of the

My html :

<section id="sub-header" class="section bg-parallax pt-0 pb-0" data-background="<%= image_path('bg/about.jpg') %>">

This directory is under the
. But i can't reach the image.

Where should i put these images ? and how can i reach images in this example

Answer Source

I tried all combinations. But solution was simple. You don't need to use rails helper functions for that. I moved my images from assets to public folder and :

  <section id="sub-header" class="section bg-parallax pt-0 pb-0" style='background:url("/bg/about.jpg")'>