问题
I have rails 4.2 working fine on development but in production env I have the following warning:
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)
however I don't have config.serve_static_assets in my app config. It might be configured somewhere.
please help how to get rid of this. thanks in advance.
回答1:
The deprecation warning you're getting is most probably caused by another gem that's setting that configuration for you. For me, we're using rails_serve_static_assets and we're using version 0.0.2
. To remove the deprecation warning, just update the gem (issue has been fixed in version 0.0.3
)
bundle update rails_serve_static_assets
回答2:
Open your environments file. (either environments/production.rb
, environments/development.rb
, environments/test.rb
) depending on which environment you are in.
Change
config.serve_static_assets
to
config.serve_static_files
回答3:
I have faced the same issue and it seems a warning and not an error, and railties update automatically the serve_static_assets to serve_static_files as per the configuration file.
Path:
railties-4.2.7\lib\rails\application\configuration.rb
Source code snippet:
# :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
来源:https://stackoverflow.com/questions/29812274/asset-pipeline-deprecation-warning-tsort-rb226