How to get rid of email regex message on Devise?

一世执手 提交于 2019-12-23 12:16:41

问题


I'm using Devise Token Auth gem and, everytime I run my test suite in Rails 4.2.5 app, I'm getting this deprecation warning from 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)

I've already added config/initializers/devise.rb file manually and have set email_regex as suggested by the message above, but the annoying message persists.

How can I disable this message?


回答1:


Related with this post, you can manage deprecation warnings according to th environment in which you are working, as said in 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.

So just change in config/environments/test.rb the value :stderr for :log

Rails.application.configure do
   ...
   # Print deprecation notices to the stderr.
   config.active_support.deprecation = :log
   ...
end

And with this the depecation warning will be in the log/test.log instead in the console output



来源:https://stackoverflow.com/questions/37240629/how-to-get-rid-of-email-regex-message-on-devise

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!