Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/heroku/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ruby on rails 在Heroku上更新到Rails 3.1时的资产管道_Ruby On Rails_Heroku_Ruby On Rails 3.1_Web Deployment - Fatal编程技术网

Ruby on rails 在Heroku上更新到Rails 3.1时的资产管道

Ruby on rails 在Heroku上更新到Rails 3.1时的资产管道,ruby-on-rails,heroku,ruby-on-rails-3.1,web-deployment,Ruby On Rails,Heroku,Ruby On Rails 3.1,Web Deployment,我刚刚将我在Heroku上的应用程序从Rails 3.0升级到3.1,我正在努力使资产管道正常工作。主要问题是,我可以从heroku日志中读取每项资产的以下行: 2011-09-03T16:35:28+00:00 app[web.1]: cache: [GET /assets/border-a3c571a354b9381740db48aeebfaa63a.jpg] miss 如果我正确理解了管道,那么对于我从浏览器发出的每个请求,这不应该是“未命中”,而是应该在缓存中找到 阅读Heroku文档

我刚刚将我在Heroku上的应用程序从Rails 3.0升级到3.1,我正在努力使资产管道正常工作。主要问题是,我可以从heroku日志中读取每项资产的以下行:

2011-09-03T16:35:28+00:00 app[web.1]: cache: [GET /assets/border-a3c571a354b9381740db48aeebfaa63a.jpg] miss
如果我正确理解了管道,那么对于我从浏览器发出的每个请求,这不应该是“未命中”,而是应该在缓存中找到

阅读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.
但“资产:预编译”任务应该是什么?我尝试从头开始用Rails3.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 isn't compiled
My application.rb有以下行:

config.assets.enabled = true

非常感谢你的帮助

您能否尝试将
config.service\u static\u assets
设置为
true

config.action_dispatch.x_sendfile_header = "X-Sendfile"
是否已添加到您的
config/environments/production.rb
文件

当您将代码推送到Heroku时,您应该会看到slug编译器AFAICT宣布的预编译。

请确保您已启动。那么


注意:我仍然会遇到“缓存未命中”,但我不认为这是真的,因为如果你的资产没有编译,你的应用程序将无法工作。

我也在想同样的事情,但这里有一个提示可以帮助你判断你的资产是否是实时编译的

  • 在本地运行rake资产:预编译
  • 对css进行一些更改,但不要重新运行rake任务
  • git添加、提交并推送到heroku
  • 如果您在步骤2中所做的更改显示在heroku上,则您知道您的应用程序正在进行实时编译

    不要忘记,您现在负责http缓存,因为清漆不再包含在celadon中,所以您需要自己设置rack cache和memcached:

    • heroku博士
    • 在heroku上安装memcached
    • 赫罗库医生
    但是,是的,我发现这也让人困惑

    还有,看看

    为了更快地进行资产预编译,您可以部分加载应用程序 通过在中设置config.assets.initialize\u on_precompilefalse config/application.rb,但在这种情况下,模板无法看到 应用程序对象或方法Heroku要求该值为假


    “------>为Rails资产管道准备应用程序”出现,但之前也出现过。但仍在获取缓存未命中…它不应该使用ngnix指令吗
    config.action\u dispatch.x\u sendfile\u header='x-Accel-Redirect'
    yes,我有Cedar堆栈。如果激活了“实时编译”,则每次缓存未命中时,它都会对其进行编译。实际上,如果我停用此选项(使用'config.assets.compile=true'),则它根本不起作用。我直接在heroku上编译资产,而不会用编译的资产污染本地存储库。使用命令:heroku run rake assets:precompile