资产管道弃用警告 tsort.rb:226

Asset pipeline DEPRECATION WARNING tsort.rb:226

我有 rails 4.2 在开发中工作正常但在生产环境中我有以下警告:

DEPRECATION WARNING: The configuration option `config.serve_static_assets` has been renamed to `config.serve_static_files` to clarify its role (it merely enables serving everything in the `public` folder and is unrelated to the asset pipeline). The `serve_static_assets` alias will be removed in Rails 5.0. Please migrate your configuration files accordingly. (called from block in tsort_each at /home/xxx/.rbenv/versions/2.2.1/lib/ruby/2.2.0/tsort.rb:226)

但是我的应用程序配置中没有 config.serve_static_assets。它可能在某处配置。

请帮忙解决这个问题。提前致谢。

打开您的环境文件。 (environments/production.rbenvironments/development.rbenvironments/test.rb)取决于您所处的环境。

改变

config.serve_static_assets

config.serve_static_files

您收到的弃用警告很可能是由另一个 gem 为您设置该配置引起的。对我来说,我们使用 rails_serve_static_assets 并且我们使用版本 0.0.2。要删除弃用警告,只需更新 gem(问题已在版本 0.0.3 中修复)

bundle update rails_serve_static_assets

我遇到了同样的问题,这似乎是警告而不是错误,railties 会自动将 serve_static_assets 更新为 serve_static_files 根据配置文件。

路径:
railties-4.2.7\lib\rails\application\configuration.rb

源代码片段:

  # :nodoc:
  SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE = <<-MSG.squish
    The configuration option `config.serve_static_assets` has been renamed
    to `config.serve_static_files` to clarify its role (it merely enables
    serving everything in the `public` folder and is unrelated to the asset
    pipeline). The `serve_static_assets` alias will be removed in Rails 5.0.
    Please migrate your configuration files accordingly.
  MSG

  def serve_static_assets
    ActiveSupport::Deprecation.warn SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE
    serve_static_files
  end

  def serve_static_assets=(value)
    ActiveSupport::Deprecation.warn SERVE_STATIC_ASSETS_DEPRECATION_MESSAGE
    self.serve_static_files = value
  end