I am using rails 3.2 and i have to set a background for one of the page and i have tried many ways and nothing went right, so looking for some good help. I have tried
background: url(<%= asset_path 'background.jpg' %>)
background: url("public/background.jpg");
background-image:url('/assets/images/background.jpg')
and nothing worked. Please help me.
I struggled with this for an entire day. Finally I got it working in both development and production by coding the css in the view that holds the background image:
Then on the sheet itself I created a div with id=tile like this:
Ruby 2.3.7 Rails 5.2.0
If you are using sass (scss), use image-url function:
I followed the suggestions above (Thank you!) - just in case it doesn't work for others either - this solution worked for me:
so instead of "background-image" I had to use "background" in my scss.
Ok, hope this helps someone!! I was in a similar situation recently looking to implement an image for a theme. This solution worked for me in a home_page_header.html.erb file provided that you have an image called blog_image.jpeg in your app/assets/images folder:
It seems that double quotes work.
Here is my example:
And the sunset jpeg is located in my assets folder.