Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Heroku is not pre-compiling my assets to prepare my app for asset pipeline

I'm having a bit of trouble getting my asset pipeline setup working with Heroku/Cedar using Rails 3.1.1

I've pushed my application and it launches successfully but there was no message that said "Preparing asset pipeline" and no static assets are being served up. No JS, CSS, or images are able to be found as there is no slug compilation time or runtime asset compilation being done.

Any help would be greatly appreciated.

They describe what should happen during deployment at this link which I'll summarize below:

With a Rails 3.1 application on Heroku Cedar when you git push heroku your assets will all be pre-compiled as part of the deploy process by using the rake task bundle exec rake assets:precompile.

like image 596
Tyler Brock Avatar asked Oct 18 '11 19:10

Tyler Brock


2 Answers

Ok so the solution was this:

I'm using mongoid which has you remove the 'rails/all' line as part of the configuration. As a result sprockets was not being loaded.

What you need to do with rails 3.1+ is also add require "sprockets/railtie" in application.rb so that sprockets are enabled. Boom, works.

This info can be found on the mongoid website here. This is useful to know for anyone who may not be loading the full 'rails/all' in application.rb, sprockets is obviously required for the asset pipeline to work.

like image 62
Tyler Brock Avatar answered Nov 16 '22 02:11

Tyler Brock


Have you seen this article on Rails 3.1 asset pipeline on Heroku - http://devcenter.heroku.com/articles/rails31_heroku_cedar. I reviewed it yesterday and picked up a good few hints from it and I've been running Rails 3.1 sites on Heroku for quite a while now.

Was this a new Rails 3.1 site or a site upgraded to Rails 3.1, things to check would be that the asset pipeline is enabled for production - by default Rails 3.1 uses

config.assets.enabled = false

in application.rb. Are you using app/assets for your assets and not public/

like image 44
John Beynon Avatar answered Nov 16 '22 04:11

John Beynon