I'm trying to deploy an admin dashboard on top of a Rails API. Currently, it's Ingress service is setup at site.com/api/admin, and Rails is searching for the assets at site.com/assets, so it doesn't find them.
How can I tell Rails to look for the assets at site.com/api/assets/admin.css? I've tried using config.assets.prefix = '/api/'
, but that seems to just change the directory the assets are precompiled to to public/api/assets
, but in application.html.erb, the stylesheet link tag is still public/assets/admin.css
, resulting in 404 errors for all assets.
You need to add the folder's path into the asset pipeline. You can do it by going to config/initializers/assets.rb
and adding the following line:
Rails.application.config.assets.paths << Rails.root.join('my', 'folder', 'path')
Or, in this case:
Rails.application.config.assets.paths << Rails.root.join('app', 'public', 'api', 'assets')
After days of troubleshooting, I tried setting config.relative_url_root
to '/api'
, and it's now finally working.