Can't get CSS working on Heroku using Rails 4 with bootstrap-sass gem Can't get CSS working on Heroku using Rails 4 with bootstrap-sass gem heroku heroku

Can't get CSS working on Heroku using Rails 4 with bootstrap-sass gem


I just now (June 13 2013)got this answer from Heroku devs whose support guided me across the barriers.This is how I got my css display from localhost working in my Heroku app.

"All you need to do is turn on asset serving in production and set the logger to stdout to get Rails4 to work on Heroku. We are currently working on smoothing out the deploy process for Rails 4 apps but for the meantime, you can just change those lines in your code and you won't need those gems." (Thanks Bret and Neil great news)

In /config/environments/production. set:

config.cache_classes = trueconfig.serve_static_files = trueconfig.assets.compile = trueconfig.assets.digest = true

I do not know about the stdout in logger so can't check that.

Do a git add . and git commit.

Make sure that /config/database.yml has:

production:  adapter: postgresql  encoding: unicode  database: Your_appname_production

You will need this info for the env command below.

Make sure you have gem 'pg' in production in your GemfileDo another git commit.

Run this command in a terminal in your app on one line:

env RAILS_ENV=production DATABASE_URL=postgresql://user:pass@127.0.0.1/Your_app_name_production bundle exec rake assets:precompile 2>&1

Where DATABASE_URL=postgresql is identical to your production adapter in the yml fileand Your_app_name_production is specified because Heroku only seems to run production.

I was advised against and did not need:

group :production do  gem 'rails_log_stdout',           github: 'heroku/rails_log_stdout'  gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'end

It errors out in bundle install and Heroku.

Don't know if this helps but I also added production to

Bundler.require(*Rails.groups(assets: %w(development test production)))

Can't remember where I saw that advice.

HTHArel


Just run bundle exec rake assets:precompile before pushing to heroku


I was able to fix this issue by adding these two gems to my application

group :production do  gem 'rails_log_stdout',           github: 'heroku/rails_log_stdout'  gem 'rails3_serve_static_assets', github: 'heroku/rails3_serve_static_assets'end

Add that, run bundle install and then push to heroku.

Your styles should start loading.