Skip to content

Heroku Cedar deployment with the Asset Pipeline

mergulhao edited this page Aug 9, 2012 · 2 revisions

If you are getting precompile errors or missing styles on Heroku, try the following:

  1. Try adding the AA assets to the precompile list in production.rb
# config/environments/production.rb
config.assets.precompile += %w( active_admin.css active_admin.js )
  1. Try placing active_admin.css.scss and active_admin.js in vendor/assets instead of app/assets. This prevents inadvertent inclusion of AA assets when you use the sprockets directive require_tree . This is the default sprockets directive in application.css for a new rails app and is why many people get confused about AA assets being required on all parts of their site. Putting the AA assets in vendor/assets prevents this problem but you could just as well put it in a subdirectory of app/assets and avoid using the require_tree directive (opting for require_directory instead).
  2. Make sure sass-rails is available when precompiling. This entails making sure that either the assets group is required during precompile or making sass-rails available in all gem groups. Often upgrades from older versions of Rails will not have the correct Bundler require statement so this is important to check if you didn't start your project on Rails 3.1+. If you can run bundle exec rake assets:precompile RAILS_ENV=production on your machine without errors and with a fake production db configured then you're good.
  3. Set up heroku-specific config as directed in their FAQ about deploying using the asset pipeline:
# config/application.rb - NOT production.rb
config.assets.initialize_on_precompile = false

Error during deploy: could not connect to server: Connection refused

You probably did not set initialize_on_precompile to false (step 4 above). This error happens when your app startup tries to connect to the database - the production database is not available during the precompile step. As such, not setting initialize_on_precompile to false causes the application to initialize and part of that process tries to connect to the database.

Clone this wiki locally