2013-08-19 39 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