2013-07-18 68 views
1

升級到Rails 4後,不再生成public/assets/manifest.yml。而是存在不同的格式化的清單 - (指紋).json。 但在我看來,服務器仍在尋找舊的manifest.yml格式,忽略.json版本?Rails 4,Heroku無法識別預編譯的清單(指紋).json

我看到類似問題的其他問題,但他們似乎被升級到Rails 4,爲rails文件添加rails_12factor,設置serve_static_assets = true等,但這些解決方案似乎沒有任何影響我的場景。

由於這個煩人的問題,我很累,沒有靈感,任何幫助將不勝感激!從Heroku的

日誌文件:

ActionController::RoutingError (No route matches [GET] "/assets/layouts/test/test.html"): 

的Gemfile:

ruby '2.0.0' 
gem 'rails', '4.0.0' 
... 
gem "compass-rails", github: "milgner/compass-rails", ref: "1749c06f15dc4b058427e7969810457213647fb8" 
... 
gem 'rails_12factor', group: :production 

production.rb

RailsFoundationAngular::Application.configure do 
    config.assets.initialize_on_precompile = false 
    config.cache_classes = true 
    config.consider_all_requests_local  = false 
    config.action_controller.perform_caching = true 
    config.serve_static_assets = true 
    config.assets.compress = true 
    config.assets.compile = false 
    config.assets.digest = true 
    config.i18n.fallbacks = true 
    config.active_support.deprecation = :notify 
    config.action_dispatch.x_sendfile_header = nil 
end 

我使用的角度和他們的UI路由器,這是部分我的routes.js.coffee其中test.html鏈接:

.state "root", 
     url: "/" 
     views: 
     "root": 
      controller: "ApplicationController" 
      templateUrl: "/assets/layouts/test/test.html" 

我也試過本地預編譯,但由於我在這裏也使用了Rails 4,所以仍然沒有創建manifest.yml,只有.json版本。 當然,一切都工作得很好的發展...

所以我的實際cuestion: 如何使Heroku的識別和使用manifest-(指紋)以.json -file,或替代方式,使這項工作?

+0

現在我實際上在這裏找到了一個可用的解決方法:[沒有路徑與Rails中的資源/圖像匹配](http://stackoverflow.com/a/11128672/2597056)。 將routes.js.coffee重命名爲routes.js.coffe.erb,並將文件重命名爲'templateUrl:「<%= asset_path('layouts/test/test.html')%>」'。 現在我只需要像這樣更改源中的每個文件引用。其實,我認爲這正是清單文件預期爲我做的事情? – RastacraZ

回答

2

答案是,Heroku已經識別並使用了manifest-(fingerprint).json -file。上面我的評論中的「解決方法」是引用這些文件的正確方法,通過這樣做,清單文件就可以像使用它的方式一樣使用。

將文件重命名爲.erb的內部鏈接,並像這樣引用:templateUrl: "<%= asset_path('layouts/test/test.html') %>"可以做到這一點。所有內部文件,圖像和html文件都應該像這樣引用。

這一切都說明得很徹底這裏:Asset-pipeline guide

現在看來如此簡單明瞭,但我真的花了很多時間試圖從一開始就避開這個錯誤的方式。 我希望這個答案可以爲別人節省時間。

+0

請你澄清這個答案?在修復之前,您的資產路徑是什麼樣的?我有同樣的問題,我的問題在這裏:http://stackoverflow.com/questions/20555906/heroku-ignores-public-assets-manifest-json – nnyby