问题
This is an app that I am upgrading to Rails 3.1, along with the asset pipeline. Everything looks peachy in development, but when I push to heroku, the images in my css are not displaying.
Couple of questions. First, should I leave these files with the css extention, or should they be renamed to either scss, or css.scss.erb?
The other question I have is how should I reference images in the css. Currently I have...
background: #B4F4FF url(/assets/img01.jpg) repeat-x left top;^M
I am pretty sure I need to replace url with either 'image_tag' or 'asset_tag'...looks like there are a few options available. Also, what should the path be?...../assets, assets/images, just the file name???
I've tried all manner of methods, and paths, and can't get this to work in Heroku. Any help appreciated!
回答1:
Wow! This was a real pain to figure out.
For me the issue centered around static pages that I had in my app. I had to add the line...
config.assets.precompile += ['static_pages.css']
to config/environments/production.rb, then compile my assets locally with
RAILS_ENV=production bundle exec rake assets:precompile
then push all that to heroku.
来源:https://stackoverflow.com/questions/12624376/getting-my-images-in-css-to-work-on-rails-and-asset-pipeline-with-upgraded-app-o