in Hacking

Rails 3.1 Assets Precompilation

Today I tried to 'release' our rails 3.1 product to the production environment. Which of course has precompiled assets.

The app deployed nicely. But when I tried to start the app, I've got the following error:

ActionView::Template::Error (locales/nl.js isn't precompiled): 
...

Deploying the app with capistrano (which precompiles my assets) did not compile my javascript-locales.

The cause of this seeems to the that the assets pipeline precompilation task, only precompiles the application.js file...

To add extra files for precompilation, place the following code in your config/application.rb:

    config.assets.precompile << "locales/*.js"  
    config.assets.precompile += %w(rails_admin/rails_admin.js rails_admin/rails_admin.css)

This examples precompiles ALL my locale files in the app/assets/locales/* directory.

And as a bonus it also compiles the assets of the the rails_admin plugin.

  1. I put my rails 3.1 application into production *yesterday*, then stayed up till midnight trying to fix this exact same issue to no avail. Couldn’t understand why precompile wasn’t touching the stylesheets or js.

    Thank you. Thank you. Thank you.

    Serendipity rocks!

    Best
    Damien

Comments are closed.