简体   繁体   中英

Ruby on Rails CSS files not found when deployed in heroku

I am using a themeforest by webster. I've added them to my ruby on rails app. It works perfectly fine in localhost. But when uploaded to heroku, the css files are not found. It wont load all the css files.

please refer to https://racepackdelivery.herokuapp.com/

`// in application.css
*= require css/plugins-css
*= require css/typography
*= require css/style
*= require css/responsive
*= require_tree .`

It can happen when config.serve_static_files is not set to true in your production.rb file. You can make it true and try deploying again.

1. Solution:

I had the same problem in rails 4 so i fixed with adding

1. Add gem in production 'rails_12factor'    
2. bundle exec rake assets:precompile

2. Solution:

To load assets in production environment:

How to load assets in production rails

Note: After following above link

rm -rf tmp/*
rm -rf public/assets/*
RAILS_ENV='production' rake assets:precompile

then restart your server

3. Solution:

Check that in /config/environments/production.rb you have these set to true

config.cache_classes = true
config.serve_static_assets = true
config.assets.compile = true
config.assets.digest = true

git add, git commit and push to heroku.

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