views:

39

answers:

2

I'm using the function for caching multiple javascript files into one:

<%= javascript_include_tag :all, :cache => true %>

The way I understand it this creates the all.js file the first time a HTML file using it is generated.

But if the app is configured to use an asset host on a seperate server that does not deliver HTML the file will not be created. Is there a way to generate all.js manually on deploy?

+3  A: 

You need to configure your deploy task in order to compress and create the file. If you use Capistrano, you can add a callback to be executed on deploy.

Otherwise, the are a couple of alternatives that offers also a more efficient solution. The standard Rails strategy only merges all files into a single one. But you can gain additional benefit by compressing and minifying the final result. For more information you can read the GitHub asset deployment strategy or the Jammit documentation.

Simone Carletti
Roger Ertesvag
A: 

A great project for javascript concatenation is sprockets, which can be found here: http://getsprockets.org/

It's really easy to setup and integrate with capistrano. Might be worth a look.

jonnii