Can't find CSS after pushing to Heroku

匆匆过客 提交于 2019-12-24 09:25:24

问题


Everything works fine when I run locally, but fails when I push to heroku. I've discovered that I need to modify all of the .css files in app/assets/stylesheets/ to have .css.scss extensions and ensure my Gemfile contains:

gem 'sass-rails', '4.0.1'
group :production, :staging do
  gem 'rails_12factor' # for heroku
end

Within my .css.scss files, I now use image-url() instead of url() to point to the fingerprinted image (fingerprinted and reorganized by heroku and asset compilation business).

in app/views/layouts/mycontrollername.html.erb:

<head>
  ...
  <%= stylesheet_link_tag "path/to/css/file" %>
</head>

But I still can't find the right path. When I look at the source, I see the path I expect except for the fingerprint: path/to/css/file.css instead of path/to/css/file-somemd5hash.css. Note that the path does NOT include assets/path/to/css/file.

http://guides.rubyonrails.org/asset_pipeline.html#coding-links-to-assets

EDIT

I've confirmed that there are no compiled css files on heroku in public/assets/. There is one application.js file (it's empty) even though I have a .js.coffee file for each controller. I have NO application.css, only a .css for each controller.


回答1:


This gem helped me get over it, which I guess will be merged into rails master soon:

gem 'sprockets_better_errors'

https://github.com/schneems/sprockets_better_errors



来源:https://stackoverflow.com/questions/20984600/cant-find-css-after-pushing-to-heroku

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