forked from activeadmin/activeadmin
-
Notifications
You must be signed in to change notification settings - Fork 0
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:
- 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 )
- Try placing
active_admin.css.scss
andactive_admin.js
invendor/assets
instead ofapp/assets
. This prevents inadvertent inclusion of AA assets when you use the sprockets directiverequire_tree .
This is the default sprockets directive inapplication.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 invendor/assets
prevents this problem but you could just as well put it in a subdirectory ofapp/assets
and avoid using therequire_tree
directive (opting forrequire_directory
instead). - Make sure
sass-rails
is available when precompiling. This entails making sure that either the assets group is required during precompile or makingsass-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 runbundle exec rake assets:precompile RAILS_ENV=production
on your machine without errors and with a fake production db configured then you're good. - 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
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.