2013-08-19 214 views
5

我们正在处理一个问题,即我们的资产正在编译slu comp编译期间没有任何问题。然而,从推迟到我们的分段和生产应用程序之后的昨天开始,我们现在遇到浏览器指出由于某种原因无法加载资产的问题。未找到heroku资产404

使用浏览器的开发者工具,我们看到了这个错误: 无法加载资源:服务器回应的404状态(未找到): /assets/application-a3b17e738ce8996d058795310e3cd9b4.js

的第一件事我们决定做的是将我们的代码库回滚到最后一次提交(这是在以前的heroku推送中完全可用的提交)。存在浏览器无法加载资源的相同问题。

使用bash,我连接到heroku实例并检出public/assets目录以确保资产实际存在。它们都在那里,在文件名之前有正确的哈希码。这些文件不是空的,清单文件看起来不错。 我不知道还有什么要尝试在这一点上。加载资产之前,我们从未遇到过问题。 heroku推送日志中没有任何内容表明任何事情在任何时候都会抛出错误。

+1

您是否曾经找到对此的答案题? – Nathan

+0

尝试关闭所有缓存,浏览器缓存和CDN。 – Chloe

回答

4

我有同样的问题。我的生产宝石中包含了rails_12factor宝石(在我的Gemfile中)后,它似乎对我来说是固定的。我发现了这一点阅读本的Heroku支持页面的第一部分之后:https://devcenter.heroku.com/articles/rails4

Logging and assets

Heroku treats logs as streams and requires your logs to be sent to STDOUT. To enable STDOUT logging in Rails 4 you can add the rails_12factor gem. This gem will also configure your app to serve assets in production. To add this gem add this to your Gemfile:

gem 'rails_12factor', group: :production

This gem allows you to bring your application closer to being a 12factor application. You can get more information about how the gem configures logging and assets read the rails_12factor README. If this gem is not present in your application, you will receive a warning while deploying, and your assets and logs will not be functional.

的“rails_12factor”创业板对创业板rails_serve_static_assetsrails_stdout_logging gem依赖。基本上,如果您不希望Rails应用程序在处理请求时使用其宝贵周期来处理资源,那么您需要找出不同的解决方案,例如CDN:https://devcenter.heroku.com/articles/using-amazon-cloudfront-cdn-with-rails