views:

28

answers:

1

Is there any way I can route assets inside of my css to where the rest of the views are pulling them? I mean, inside the CSS can I call url_for or css_for or something like that in order to have the images go through the assets router?

Thank you in advance!

+1  A: 

You can use a controller action to render your CSS (with an erb template) and set the content type to text/css.

Take a look at this blog post from Josh Susser on dynamically generated stylesheets. It is from 2006 but the technique described is still applicable.

mikej
That is really helpful! Actually, we considered using it because as an asset, you can vary which server gets called for cache using %d wildcards. However, if we have to invoke rails to generate CSS, it might be faster to just to hardcode one Cache server for CSS.
tesmar