I wanted to set the asset host in my Rails project to point to my CDN. The CDN is pointing directly to the assets directory so that I didn’t have to deal with duplicative content being found via crawlers if they crawl my CDN’s domain and I had pointed it to the root of my site. The problem is if I set my asset_prefix to ‘’ it’ll cause the files to be stored via sprockets so they are referenced without the assets directory but I wanted to have them still in the assets directory so the origin can reference that.
I was able to get things working by hacking in a change to sprocket-rails asset helper to not use the asset prefix but it’s still there for the purposes of pre compilation so the assets folder can be pointed to by my CDN.
Is there some other way to go about accomplishing this without needing to hack the asset helper logic? Wondering how others have dealt with this issue themselves. Alternatively I guess I could have uploaded my assets to s3 and use my CDN pointing to that and then I wouldn’t need to worry about the root of my site being accessible it was just easier to avoid s3 completely by forcing sprocket-rails to just not append that prefix when generating the asset paths.