Rails 4,Heroku不能识别预编译的清单 - (指纹).json [英] Rails 4, Heroku doesn't recognize precompiled manifest-(fingerprint).json
问题描述
升级到Rails 4后,public / assets / manifest.yml不再生成。而是存在不同的格式化的清单 - (指纹).json。
但在我看来,服务器仍在寻找旧的manifest.yml格式,忽略.json版本?
我看到其他问题基于类似的问题,但他们似乎被升级到Rails 4,将rails_12factor添加到gem文件,设置serve_static_assets = true等等,但这些解决方案似乎没有任何影响,在我的情况。
由于这个令人讨厌的问题,我感到很累,并且没有受到鼓舞,任何帮助都将不胜感激!
Heroku的日志文件:
ActionController :: RoutingError(没有路由匹配[GET]/assets/layouts/test/test.html):
Gemfile:
ruby' 2.0.0'
gem'rails','4.0.0'
...
gemcompass-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
我使用的是Angular和他们的ui-router,这是我的routes.js.coffee中test.html链接的部分:
.stateroot,
url:/
views:
root:
controller:ApplicationController
templateUrl:/assets/layouts/test/test.html
我也尝试过预编译loc盟友,但因为我在这里也使用Rails 4,所以仍然没有创建manifest.yml,只有.json版本。
当然,在开发过程中所有的工作都是完美的......
所以我的实际提示:
我让Heroku识别并使用manifest-(fingerprint).json -file或其他方法来实现这个功能?
答案是,Heroku已经识别并使用了清单(指纹).json文件。在我上面评论中的解决方法是引用这些文件的正确方法,通过这样做,清单文件就可以被使用。
重命名带有.erb内部链接的文件,并像这样引用: templateUrl:<%= asset_path('layouts / test / test.html')%>
就是这样做的。所有内部文件,图像和html文件应该像这样被引用。
这里所有的描述都非常透彻:资产管道指南
看起来很简单直接现在,但我真的花了很多时间试图从一开始就错误地解决这个问题。
我希望这个答案可以节省别人的时间。
After upgrading to Rails 4, public/assets/manifest.yml is not generated anymore. Instead the different formatted manifest-(fingerprint).json is present. But it seems to me that the server is still looking for the old manifest.yml format, ignoring the .json version?
I see other questions based on similar problems, but they seems to be sovled by upgrading to Rails 4, adding rails_12factor to gem file, setting serve_static_assets = true, etc., but none of these solutions seems to have any effect in my scenario.
I am tired and uninspired due to this annoying problem, any help will be appreciated!
Logfile from 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
I am using Angular and their ui-router, and this is the part of my routes.js.coffee where the test.html is linked:
.state "root",
url: "/"
views:
"root":
controller: "ApplicationController"
templateUrl: "/assets/layouts/test/test.html"
I have also tried precompiling locally, but as I am using Rails 4 here as well, still no manifest.yml is created, only the .json version. Of course, everything is working just perfectly in development...
So my actual cuestion: How do I make Heroku recognize and use the manifest-(fingerprint).json -file, or alternative ways to make this work?
The answer is, that Heroku already does recognize and use the manifest-(fingerprint).json -file. The "workaround" in my comment above, is the proper way to reference these files, and by doing so, the manifest-file is used the way it's ment to be used.
Renaming the file with the internal link to .erb, and referencing like this: templateUrl: "<%= asset_path('layouts/test/test.html') %>"
does the trick. All internal files, images, and html -files should be referenced like this.
It's all described very thoroughly here: Asset-pipeline guide
It seems so simple and straightforward now, but I really spent a lot of time trying to get the wrong way around this from the beginning. I hope this answer can save the time for someone else.
这篇关于Rails 4,Heroku不能识别预编译的清单 - (指纹).json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!