在调试this problem的过程中,我尝试在本地生产模式下运行我的应用程序,但它不提供任何资产。另外,我在Heroku应用程序中有一个暂存环境(与我的生产Heroku应用程序分开),它现在也显示没有任何资产的HTML。
要调试,我:
rake assets:precompile
rails s -e production
Reload the page to get source for: http://localhost:3000/assets/application-e1f3e0c864a153c7iu66f8772a886376.css
Production.rb :
config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
config.assets.compress = false
config.assets.compile = false
config.assets.digest = true
Staging.rb :
config.cache_classes = true
config.consider_all_requests_local = false
config.action_controller.perform_caching = true
config.serve_static_assets = true
config.static_cache_control = "public, max-age=3600"
config.assets.compress = false
config.assets.compile = false
config.assets.digest = true
application.rb中:
config.assets.enabled = true
config.assets.version = '1.0'
config.assets.initialize_on_precompile = false
以下是我在 layout / application.html.erb 中链接样式表和javascript的方法:
<%= stylesheet_link_tag "application", :media => "screen, handheld" %>
<%= javascript_include_tag "application" %>
答案 0 :(得分:7)
所以问题是内存存储设置为config.cache_store = :dalli_store
导致错误并将其设置为config.cache_store = :memory_store
解决了它。
答案 1 :(得分:6)
这是一种猜测,但是编译资产不需要设置为true吗?
config.assets.compile = true
我觉得你需要像这样编译资产:
rake assets:precompile RAILS_ENV='production'