Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Rails 3.2.1 heroku asset precompile error

I have added these two lines to application.rb:

config.assets.initialize_on_precompile = false

config.assets.compile = true

However I still get errors when I push to Heroku:

2012-02-05T09:48:34+00:00 app[web.1]: Completed 500 Internal Server Error in 3ms
2012-02-05T09:48:34+00:00 app[web.1]: 
2012-02-05T09:48:34+00:00 app[web.1]: ActionView::Template::Error (bootstrap.css isn't precompiled):

Any suggestions?

like image 356
Richard Burton Avatar asked Feb 05 '12 09:02

Richard Burton


3 Answers

By the looks of it you have a bootstrap.css file that is not included properly in your manifest file within app/assets/stylesheets and that you're probably also calling directly from a stylesheet_tag.

There are a couple of approaches to this:

  1. You could add a line to your environment config file which will ensure the css file you're calling is precompiled:

config.assets.precompile += %w( bootstrap.css )

…for example.

  1. This is the one i would probably do; include the bootstrap.css file in a manifest file inside `app/assets/stylesheets' as mentioned above. Your manifest file will look something like this (not sure if the formatting of this will appear correctly on here, so i have also created a Gist: https://gist.github.com/1753229):

/* *= require bootstrap */

/* rest of file omitted */

You might need to require more files than that depending on what your css setup is.

like image 74
Pete Avatar answered Nov 17 '22 17:11

Pete


Try to use rake assets:precompile before committing your code and pushing it to heroku.

like image 32
liviu.r2 Avatar answered Nov 17 '22 17:11

liviu.r2


read this, it's a tutorial on how to get rails 3.2.1 (and ruby 1.9.3) running on heroku. You can obviously skip the bits you don't need but it should explain why these problems are happening and how to fix them.

Also, read this article by david rice, author of the useful asset_sync gem. It will help you sort this out.

like image 3
stephenmurdoch Avatar answered Nov 17 '22 16:11

stephenmurdoch