CSS loading locally but not in Heroku for a rails app

CssRuby on-RailsHerokuTwitter Bootstrap

Css Problem Overview


I'm following a rails prelaunch signup tutorial. Bootstrap was working fine deployed on heroku, but then I modified the bootstrap_and_override file to include a logo. When launching a rails server locally and viewing, the style is as I intended with bootstrap and the new header logo appearing.

Like I did before, I ran rake assets:precompile and pushed to git - followed this tutorial http://railsapps.github.com/rails-heroku-tutorial.html which worked before showing the css while on heroku. The html is showing but it looks like css and bootstrap are missing.

Does anyone have any ideas?

Css Solutions


Solution 1 - Css

Run bundle exec rake assets:precompile on your local code

Commit the changes and deploy to heroku

Solution 2 - Css

Had the same exact problem, I don't know if it will help other in the future, but I got this on my "git push heroku master" push:

WARNINGS:

    Include "rails_12factor" gem to enable all platform features

Updated my gemfile,

    *group :production, :staging do
      gem 'pg'
      gem 'rails_12factor'
    end*

Ran it again, to my delight it installed these:

    Installing rails_serve_static_assets (0.0.1)
           Installing rails_stdout_logging (0.0.1)
           Installing rails_12factor (0.0.2)

Site worked perfect after that. Hope that helps someone, I'm new to all this.

Solution 3 - Css

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.

Solution 4 - Css

If your using sass...before you go through all this other trouble...make sure your not mixing .css and .scss files in your assets folder.
Heroku seems to have some trouble mixing the two when compiling assets. I can't explain why of if its an accurate explanation...but, in my own experience all I had to do to fix this was simply rename any .css files to .scss.

Solution 5 - Css

Figured it out after trying about everything stackoverflow could suggest. I simply checked git status, saw I had a bunch of uncommitted files (thought this would have been picked up by git push heroku master), then added, committed and pushed to git. Then I started over, ran bundle install, precompiled assets and deployed to heroku and it is working.

Solution 6 - Css

I got the same problem in rails4 fixed with adding a. gem 'rails_12factor' b. bundle exec rake assets:precompile

Solution 7 - Css

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

Solution 8 - Css

This is a long shot, but if you're using Chrome try pressing Ctrl+Shift+R to reload the page as Chrome can sometimes cache old CSS settings.

Solution 9 - Css

I just went through similar problems with an app. Check out THIS post...

Solution 10 - Css

This issue can also happen when you are cloning an app and using a CDN for your assets.

Comment out config.action_controller.asset_host in production.rb if your heroku app is a staging site.

Solution 11 - Css

I had to run heroku run rake css:rebuild

Attributions

All content for this solution is sourced from the original question on Stackoverflow.

The content on this page is licensed under the Attribution-ShareAlike 4.0 International (CC BY-SA 4.0) license.

Content TypeOriginal AuthorOriginal Content on Stackoverflow
Questionpvskisteak5View Question on Stackoverflow
Solution 1 - CssConnor LeechView Answer on Stackoverflow
Solution 2 - CssPeter J BondView Answer on Stackoverflow
Solution 3 - CssFrancisco QuinteroView Answer on Stackoverflow
Solution 4 - CsshellionView Answer on Stackoverflow
Solution 5 - Csspvskisteak5View Answer on Stackoverflow
Solution 6 - Csspraaveen V RView Answer on Stackoverflow
Solution 7 - CssTaimoor ChangaizView Answer on Stackoverflow
Solution 8 - CssGarry TiscovschiView Answer on Stackoverflow
Solution 9 - CssMark LocklearView Answer on Stackoverflow
Solution 10 - CssKieranView Answer on Stackoverflow
Solution 11 - CssWayfererView Answer on Stackoverflow