In config/environments/production.rb
, make sure your application is configured to serve static assets:
config.serve_static_assets = true
By default, Rails assumes that your static assets will be served elsewhere (e.g. Apache, Nginx, etc.)
Frage
None of my assets, such as images, javascripts, and styling features are showing up when I run the following command:
RAILS_ENV=production rails s
Then I go to http://localhost:3000
and the application comes up, but has no styling at all.
I did precompile the assets:
➜ myapp git:(master) ✗ bundle exec rake assets:precompile --trace
Invoke assets:precompile (first_time)
Execute assets:precompile
/Users/me/.rvm/rubies/ruby-1.9.3-p545/bin/ruby /Users/me/.rvm/gems/ruby-1.9.3-p545@myapp/bin/rake assets:precompile:all RAILS_ENV=production RAILS_GROUPS=assets --trace
Invoke assets:precompile:all (first_time)
Execute assets:precompile:all
Invoke assets:precompile:primary (first_time)
Invoke assets:environment (first_time)
Execute assets:environment
Invoke environment (first_time)
Execute environment
Invoke tmp:cache:clear (first_time)
Execute tmp:cache:clear
Execute assets:precompile:primary
Invoke assets:precompile:nondigest (first_time)
Invoke assets:environment (first_time)
Execute assets:environment
Invoke environment (first_time)
Execute environment
Invoke tmp:cache:clear (first_time)
Execute tmp:cache:clear
Execute assets:precompile:nondigest
This works just fine in Safari
, can't figure out why Chrome
won't load the stuff. I cleared out the browser cache also.
Lösung
In config/environments/production.rb
, make sure your application is configured to serve static assets:
config.serve_static_assets = true
By default, Rails assumes that your static assets will be served elsewhere (e.g. Apache, Nginx, etc.)