Reputation: 13467
I'm using a CDN and I have a CNAME for static.example.com
pointing towards the rails public/assets
folder.
The problem is I'm using Nginx to create that subdomain, and because it's using the assets folder as it's root, assets are now stored at:
static.example.com/hi.jpg
But asset_path
wants to look in static.example.com/assets/hi.jpg
I don't want to change the location of where assets are compiled or anything that physically changes how the asset pipeline currently works - I only want to specify a new 'root' prefix when an asset is called upon.
Or, I was thinking of how I could use nginx to 'link' those 2 paths above, so that when they visit /assets/hi.jpg
it would actually look in /hi.jpg
, although I'm not sure how to do this with Nginx.
Either solution I would be okay with.. Thanks guys.
Upvotes: 3
Views: 3186
Reputation: 3144
You can set the url path via config.assets.prefix
and the place where assets are looked for is configured with config.assets.paths
.
From the guide on configuring assets:
config.assets.paths
contains the paths which are used to look for assets. Appending paths to this configuration option will cause those paths to be used in the search for assets.
config.assets.prefix
defines the prefix where assets are served from. Defaults to /assets.
Upvotes: 3