Amazing until it comes to deployment. A tough subject with Rails in general. And the asset pipeline doesn't make it any easier. Because it heavily depends on a working javascript runtime at the production site. But who wants to have a javascript runtime on a production server? If one is not using Node.js as a backend framework, that is? Correct: nobody with a sane right half of a brain.
The office documentation on the asset pipeline has some kind of a solution:
If you do not have write access to your production file system, you can call this task locally and then deploy the compiled assets.
It does not, however, really say how to do so. You have basically two options:
- Precompile the assets locally and check them into your favourite version control system.
- This works. The precompilation puts everything into
public/assets/. You check this in. And Capistrano handles everything else magically.
The trouble with this approach is, though, that it isn't really clean and doesn't feel right. Why? Because compiled things should not end up version controlled. And because you mess up your repository with potentially old and outdated files that have an MD5 fingerprint in their filename. An elegant solution looks different. - Precompile the assets and copy the result over to your production site when deploying everything else as well.
- This looks way better.
The only question is: How? Deployment is – hopefully – done via Capistrano. Which – for most of us – works like magic. Which is generally a good thing. So take a breath of fresh air, fill up your glass of red wine, and head over to: Stackoverflow, of course. There, Aaron Renoir shows a code snipped that you just need to add toconfig/deploy.rb, adjust some paths, and: et voilà, done.
- Add the above mentioned code snipped to your
deploy.rb. - Run
bundle install --without assetson the production site. - Run
bundle exec rake assets:precompilelocally. - Run
env RAILS_ENV=production cap deploylocally. - Watch the magic happen.
So, that's what you do:
Now, who again is saying that Rails seems to be slowly turning towards being the new Java of web development? Makes one think, doesn't it?

