Reputation: 1142
I have a css which contains this:
font.css.erb
@font-face {
font-family: 'thsarabun';
src: url('<%= asset_data_uri('THSarabunNew.woff') %>');
}
Everything works fine in the development environment.
But when I want to use it in production environment. I decided to use passenger with Apache2, I want the app to be located at http://localhost/rails-app
When I precompile the assets with this command:
RAILS_ENV=production rake assets:precompile
I got the application-<hash>.css
like this:
@font-face{
font-family:'thsarabun';
src:url('/assets/THSarabunNew-<hash>.woff');
}
which URL is wrong, instead, it should be /rails-app/assets/THSarabunNew-<hash>.woff
.
How can I fix this?
Regards, Sarun
Upvotes: 0
Views: 670
Reputation: 219
To run your Rails app from a subdirectory you need to change the config.
If it is just on localhost that you want this put the following in config/environments/production.rb
:
YourAppName::Application.configure do
...
config.action_controller.relative_url_root = '/rails-app'
end
See if that works for you.
Upvotes: 1
Reputation: 1798
You can set the asset prefix value in config/production.rb
. The default is '/assets'. So in your case it would be:
config.assets.prefix = "/rails-app/assets"
Upvotes: 0