问题
I have a mysterious problem in my rails application, which I cannot fix.
The thing is that I want to precompile my CSS and JavaScripts and run the server on the staging environment locally to check if everything is ok, before I deploy to the server.
I run this command to precompile the files:
rake assets:precompile RAILS_ENV=staging
To start the server in staging environment i run this command:
rails s -e staging
The files are being precompiled successfully and placed in the public/assets folder, but can not be loaded in the browser, and I cannot access the files manually from the browser either.
My staging.rb environment file looks like this:
# Code is not reloaded between requests
config.cache_classes = true
# Full error reports are disabled and caching is turned on
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
# Disable Rails's static asset server (Apache or nginx will already do this)
config.serve_static_assets = false
config.static_cache_control = "public, max-age=2592000"
config.action_controller.perform_caching = true
# Compress JavaScripts and CSS
config.assets.compress = true
config.assets.debug = true
# Don't fallback to assets pipeline if a precompiled asset is missed
config.assets.compile = false
# Generate digests for assets URLs
config.assets.digest = true
config.assets.initialize_on_precompile = true
# Use a different cache store in production
#config.cache_store = :dalli_store, 'localhost:11211'
# Precompile additional assets (application.js, application.css, and all non-JS/CSS are already added)
config.assets.precompile += %w( .svg .eot .woff .ttf )
In using following versions of ruby and rails:
Ruby v. 1.9.3 Rails v. 3.2.14
回答1:
Solved the problem by outcommenting the line:
config.serve_static_assets = false
来源:https://stackoverflow.com/questions/20254739/rails-precompile-assets-cannot-access-precompiled-files-locally