Reputation: 45
I'm taking a course in Web-development and have just started with Ruby on Rails. The thing i'm trying to figure out now is how i can set a background image with scss.
My image is in app/assets/images.
The things i have tried is:
img-url(asset_path 'logo.png')
image-url('<%= asset_path 'logo.png' %>')
url('/asset/logo.png');
and a few more. But the image does not show. I have read on stackOverflow on many people asking this question, but all the solutions in there did not work for me.
Any suggestion on how i can achieve this?
Thanks.
Upvotes: 3
Views: 708
Reputation: 33420
When working with CSS files and images you have two options url
and path
:
image-url("logo.png") # url(/assets/logo.png)
image-path("logo.png") # "/assets/logo.png"
If you want to work with images, font, video, audio, JavaScript and/or stylesheet files then you can use the generic form
asset-url("logo.png") # url(/assets/logo.png)
asset-path("logo.png") # "/assets/logo.png"
See the ActionView::Helpers::AssetUrlHelper
for further information.
Upvotes: 2