我刚刚将Heroku上的应用程序从Rails 3.0升级到3.1,我正在努力使资产管道工作.主要问题是我可以从heroku日志中读取以下类型的行,用于每个资产:
2011-09-03T16:35:28+00:00 app[web.1]: cache: [GET /assets/border-a3c571a354b9381740db48aeebfaa63a.jpg] miss
Run Code Online (Sandbox Code Playgroud)
如果我正确理解了管道,那么对于我从浏览器发出的每个请求,都不应该"错过",但应该在缓存中找到它.
阅读Heroku文档,您可以找到以下解释:
Rails 3.1 provides an assets:precompile rake task to allow the compilation penalty to be paid up front rather than each time the asset is requested. If this task exists in your app we will execute it when you push new code.
Run Code Online (Sandbox Code Playgroud)
但是,"资产:预编译"任务应该如何?我尝试从头开始使用rails 3.1构建一个项目以试图查找,但在裸项目中没有这样的任务.或者我错过了什么?我怎么能让资产在缓存中找到?也许只是配置问题.
这些是我的生产配置文件的选项:
config.serve_static_assets = false
config.assets.compress = true
config.assets.compile = true # If I turn this off I get a 500 error and logs say that an asset …Run Code Online (Sandbox Code Playgroud)