Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selectively disable asset.digest in Rails 3, so external site can include stylesheet

The aim:

I would like a Tumblr blog to pull CSS from a Rails app's asset directory.

This means I can use SASS, Compass and other sitewide CSS to generate the styling.

This also means if anything is updated in low-level CSS, tumblr.css will be regenerated along with the regular cap deploy, and Tumblr's appearance will change automatically.

The problem:

The Rails 3 asset pipeline adds a hash to the filename, e.g.:

tumblr-c6ec969ce054623163b9404f6c8330e9.css

Therefore the Tumblr template can't include it unless I update the URL manually every time it changes.

Is there a way to either selectively disable asset.digest for one file, or to explicitly generate a single CSS file from SASS, without going through the whole asset pipeline? Or maybe to generate an automatic alias or something?

like image 389
Leo Avatar asked Feb 28 '12 21:02

Leo


1 Answers

You will not have to disable the digests at all.

When Rails precompiles the assets, it adds digests to all the files. However it also creates identical files without digests. So both the following files will load the same css:

  • tumblr-c6ec969ce054623163b9404f6c8330e9.css
  • tumblr.css

If you check the public/assets directory after precompilation you should see both files.

Hope this makes helps.

like image 157
Phil Bottomley Avatar answered Oct 21 '22 18:10

Phil Bottomley