3

In the folder assets/images/default/user I stored an image banner.png.

How can I add this image direct in the following background-image?

<div class="banner-img" style="background-image: url('/assets/default/users/banner.png');"></div>
2
  • or this one url(<%= asset_path 'banner.png' %>) Commented Apr 3, 2016 at 20:47
  • thank you. Now fine with url(<%= asset_path 'banner.png' %>) Commented Apr 3, 2016 at 20:51

1 Answer 1

8

Rails Assets: Rails Assets Doc.

asset-url("rails.png") becomes url(/assets/rails.png)
asset-path("rails.png") becomes "/assets/rails.png"

In your case supposed to be like this:

url(<%= asset_path 'banner.png' %>) 
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.