【发布时间】:2020-04-16 21:33:53
【问题描述】:
有人用Ruby 2.7.0解决了这个问题吗?
我使用rbenv 并安装了Ruby v2.7.0,然后使用Rails v6.0.2.1 创建了一个Rails 项目。
目前,通过运行其中一个
rails s
rails s -u puma
rails s -u webrick
服务器已启动,网站已提供服务,但在 Console 日志中我看到两条警告消息:
local:~/rcode/rb27$ rails s
=> Booting Puma
=> Rails 6.0.2.1 application starting in development
=> Run `rails server --help` for more startup options
.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call
.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/static.rb:110: warning: The called method `initialize' is defined here
Puma starting in single mode...
* Version 4.3.1 (ruby 2.7.0-p0), codename: Mysterious Traveller
* Min threads: 5, max threads: 5
* Environment: development
* Listening on tcp://127.0.0.1:3000
* Listening on tcp://[::1]:3000
因此,警告消息是:
**.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/stack.rb:37: warning: Using the last argument as keyword parameters is deprecated; maybe ** should be added to the call**
**.rbenv/versions/2.7.0/lib/ruby/gems/2.7.0/gems/actionpack-6.0.2.1/lib/action_dispatch/middleware/static.rb:110: warning: The called method `initialize' is defined here**
【问题讨论】:
-
位置参数和关键字参数在 Ruby 3.0 中是分开的。这只是一个警告。 Rails 充满了这种模式。 ruby-lang.org/en/news/2019/12/12/…
-
@JoshBrody 非常感谢你。我看到了这个链接,并且有一些关于切换警告的建议,例如“如果您想禁用弃用警告,请使用命令行参数 -W:no-deprecated 或在您的代码中添加 Warning[:deprecated] = false。 "但我正在考虑为 actionpack v6.0.2.1 提供更好的解决方案/修复
-
全面隐藏弃用警告是个坏主意,尤其是当您想顺利进行未来的升级时。
-
@Vlad 同意,但暂时减少日志噪音是可以的(如果你知道自己在做什么)
标签: ruby-on-rails ruby warnings ruby-on-rails-6 ruby-2.7