gpt4 book ai didi

ruby-on-rails-4 - 如何摆脱 Devise 上的电子邮件正则表达式消息?

转载 作者:行者123 更新时间:2023-12-01 06:07:03 24 4
gpt4 key购买 nike

我正在使用 Devise Token Auth gem 并且每次我在 Rails 4.2.5 应用程序中运行我的测试套件时,我都会收到来自 Devise 的弃用警告:

DEPRECATION WARNING: [Devise] config.email_regexp will have a new default on Devise 4.1 To keep the current behavior please set in your config/initializers/devise.rb the following:

Devise.setup do |config|
config.email_regexp = /\A[^@\s]+@([^@\s]+\.)+[^@\W]+\z/
end

If you want to use the new default:

Devise.setup do |config|
config.email_regexp = /\A[^@\s]+@[^@\s]+\z/
end

. (called from block in tsort_each at /usr/local/lib/ruby/2.2.0/tsort.rb:226)



我已经手动添加了 config/initializers/devise.rb 文件并设置了 email_regex正如上面的消息所建议的那样,但烦人的消息仍然存在。

如何禁用此消息?

最佳答案

与此相关 post ,您可以根据您工作的环境管理弃用警告,如 rails guides 中所述。 :

active_support.deprecation_behavior Sets up deprecation reporting for environments, defaulting to :log for development, :notify for production and :stderr for test. If a value isn't set for config.active_support.deprecation then this initializer will prompt the user to configure this line in the current environment's config/environments file. Can be set to an array of values.



所以只需更改 config/environments/test.rb :stderr :log
Rails.application.configure do
...
# Print deprecation notices to the stderr.
config.active_support.deprecation = :log
...
end

有了这个, depecation 警告将在 log/test.log 中。而是在控制台输出中

关于ruby-on-rails-4 - 如何摆脱 Devise 上的电子邮件正则表达式消息?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37240629/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com