1

升级到 Rails 4 后,不再生成 public/assets/manifest.yml。相反,存在不同格式的 manifest-(fingerprint).json。但在我看来,服务器仍在寻找旧的 manifest.yml 格式,忽略 .json 版本?

我看到基于类似问题的其他问题,但它们似乎可以通过升级到 Rails 4、将 rails_12factor 添加到 gem 文件、设置 serve_static_assets = true 等来解决,但这些解决方案似乎都没有在我的场景中产生任何影响。

由于这个烦人的问题,我很累而且没有灵感,任何帮助将不胜感激!

Heroku 的日志文件:

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

宝石文件:

ruby '2.0.0'
gem 'rails', '4.0.0'
...
gem "compass-rails", github: "milgner/compass-rails", ref: "1749c06f15dc4b058427e7969810457213647fb8"
...
gem 'rails_12factor', group: :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 的部分:

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

我也尝试过在本地进行预编译,但由于我在这里也使用 Rails 4,仍然没有创建 manifest.yml,只有 .json 版本。当然,一切都在开发中完美运行......

所以我的实际提示: 我如何让 Heroku 识别和使用 manifest-(fingerprint).json -file,或者其他方法来完成这项工作?

4

1 回答 1

2

答案是,Heroku 已经识别并使用 manifest-(fingerprint).json 文件。我上面评论中的“解决方法”是引用这些文件的正确方法,通过这样做,清单文件将按照它的使用方式使用。

使用指向 .erb 的内部链接重命名文件,并像这样引用:templateUrl: "<%= asset_path('layouts/test/test.html') %>"就可以了。所有内部文件、图像和 html 文件都应该像这样引用。

这一切都在这里进行了非常详尽的描述:资产管道指南

现在看起来如此简单明了,但我真的花了很多时间试图从一开始就解决这个问题。我希望这个答案可以为其他人节省时间。

于 2013-07-19T08:29:54.680 回答