简体   繁体   中英

Rails 4 Amazon S3 background url images file not found

Is there a way to make url in css to work with asset pipeline Like the one below?

background: url("../assets/pattern/black_paper.png")

I'm getting file not found and I'm using S3 and Heroku on Rails 4.

You need to:

  1. Rename all your CSS files to css.erb
  2. change your snippet of code to:

    background: url(<%= asset_path '/pattern/black_paper.png' %>)

Try

background: asset_url("pattern/black_paper.png");

It works for me without renaming CSS files.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM