Devise: Deprecation warning in Rails 6.0.0.rc1 for email uniqueness validation

Created on 25 Apr 2019  ·  8Comments  ·  Source: heartcombo/devise

Environment

  • Ruby 2.5.3
  • Rails 6.0.0.rc1
  • Devise 4.6.2

Current behavior

DEPRECATION WARNING: Uniqueness validator will no longer enforce case sensitive comparison in Rails 6.1. To continue case sensitive comparison on the :email attribute in User model, pass `case_sensitive: true` option explicitly to the uniqueness validator.

Expected behavior

No deprecation warning

Possible solution

Since case_sensitive seems to be an option since rails 5 this could be added without breaking backwards compatibility:

# devise/models/validatable.rb
if Devise.activerecord51?
  validates_uniqueness_of :email, allow_blank: true, if: :will_save_change_to_email?, case_sensitive: true
[...]
PR attached

Most helpful comment

All 8 comments

Hello @shanehofstetter, thanks for reporting this.

Yeah, that seems like a good solution. Do you want to open a pull request for this or should I assign it for someone else?

I thought this was supposed to already be in the most current released version, but I'm still seeing this deprecation warning come up. I'm running:
ruby 2.6.4
rails 6.0.0
devise 4.7.1
Any ideas why this would be?

@mgmodell have you restarted spring after updating? (it may still have previous version in memory)

Not related: be careful with 2.6.4 (https://bugs.ruby-lang.org/issues/16136)

@Vasfed I killed all spring processes and then, for good measure, I went ahead and restarted my Mac and still I get the warnings.

@mgmodell Can you provide us a sample application that reproduces the issue?

@tegon - Sorry about this (and for taking so long to respond). It turns out the error seems to be coming from devise-multi_email.

How to hide this message on start rspec?

Was this page helpful?
0 / 5 - 0 ratings