弃用警告:配置选项`config.serve_static_assets`已重命名为`config.serve_static_files`

问题描述 投票:0回答:2

到目前为止我的rails应用程序运行完美,但是,像往常一样运行bundle exec rails server命令启动我的Web服务器进行开发后,我收到此错误消息:

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 <top (required)> at /home/jack/Desktop/Rails/MegsBlog/config
/environments/development.rb:2)

香港专业教育学院尝试更改配置文件中的方法名称,如其他社区建议,但仍然没有运气,我的应用程序中的一切工作,除了没有图像,我肯定是由于方法名称更改

ruby-on-rails ruby linuxmint
2个回答
1
投票

这可能会迟到,但我刚刚遇到这个问题设置了config.serve_static_files = true。 问题是我需要清除资产管道和预编译,所以我在本地使用了这个命令: rake assets:clean && rake assets:clobber && rake assets:precompile。 请注意,您应该保留app/assets/中的图像和所有样式和javascript,而不是public/。 我希望你已经解决了你的问题,或者如果没有,也许这可以帮助你和其他人,或者你可以与我们分享你如何解决它。谢谢!


0
投票

更新Rails版本后,serve_static_assets方法更改为serve_static_files。实际上它只是一个名称更改,因此您不应期望应用程序行为的任何更改。重命名配置而不更改其值,警告将消失。

© www.soinside.com 2019 - 2024. All rights reserved.