Skip to content

Rails Asset Pipeline

technicalpickles edited this page Aug 26, 2012 · 3 revisions

Rails 3.1 introduced, among other things, the asset pipeline. Read all about it over the official documentation.

There are a few requirements for using asset precompilation with Moonshine:

  • revision 0eeb5c6377365f8f4ace6f3a33db08e23506d553 or later of moonshine
  • a Rails 3.1+ app with assets enabled (ie config.assets.enabled = true)
  • a javascript interpreter (more on this in a second)
  • config/deploy.rb does not load 'deploy/assets'

To get started, enable assets for moonshine in your config/moonshine.yml:

:assets:
  :enabled: true

You'll also need a javascript interpretter. We recommend using Node.js via moonshine_nodejs. This uses packages from an Ubuntu PPA, which avoids surprise long-running compiles on deploy.

Install it with:

script/rails plugin install git://github.com/bigcartel/moonshine_nodejs.git

Then add it to your @app/manifests/application_manifest.rb@:

recipe :nodejs

Troubleshooting

Moonshine follows the conventions laid out in the official documentation. There is one significant difference though that may cause some errors:

load 'deploy/assets'

Do not try to load this recipe. A few reasons:

  • asset precompilation already happens during moonshine:apply
  • the deploy/asset recipes tries to invoke rake assets:precompile before moonshine runs @bundle install@
Clone this wiki locally