rails/rails — Issue #3677: asset_path raising exception when using asset_host is a Proc
Author: hukl
Created: 2011-11-18 14:15:54+00:00
State: open

Usecase:

My app with 2mio daily users uses a CDN to deliver assets. 80% of users use HTTP and 20% HTTPS. Therefor the request protocol should be reflected in the CDN url as SSL CDN traffic at a certain volume is much more expensive.

Now when I precompile assets like stylesheets which contain asset_path( source ) calls, it crashes because at that point no request object for the proc is present. I think this unnecessary because if stylesheets are loaded from the CDN than assets referenced in them with relative urls will use the CDN host automatically so I don't need the host within stylesheets / js files.

So instead of raising an exception I'd rather not set the host in the stylesheets and use relative urls as if the asset host wasn't set at all.