Getting my images in css to work on rails and asset pipeline with upgraded app on Heroku

送分小仙女□ 提交于 2019-12-21 06:39:09

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!