【问题标题】:Asset pipeline DEPRECATION WARNING tsort.rb:226资产管道弃用警告 tsort.rb:226
【发布时间】:2015-04-23 02:00:05
【问题描述】:

我的 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。它可能在某处进行了配置。

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

【问题讨论】:

  • "配置选项config.serve_static_assets 已重命名为config.serve_static_files ...请相应地迁移您的配置文件。"所以照它说的去做。进入您的配置文件并将serve_static_assets 更改为serve_static_files

标签: ruby-on-rails asset-pipeline


【解决方案1】:

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

bundle update rails_serve_static_assets

【讨论】:

  • 对我来说不是因为这个 gem,而是 bundle update 解决了这个问题
  • 嗯,您应该尝试找出在运行 bundle update 时更新了哪些 gem,并尝试一次只更新一个 gem。如果这样可以解决问题,请将其添加为另一个答案。这很可能会帮助其他用户。
【解决方案2】:

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

改变

config.serve_static_assets

config.serve_static_files

【讨论】:

    【解决方案3】:

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

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

    源码sn-p:

      # :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
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-02-09
      • 1970-01-01
      • 2021-11-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多