Skip to content

Commit

Permalink
Fix for Deprecation warning in Rails 6.0.0 (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
mgmodell authored and allenwq committed Oct 9, 2019
1 parent b216bed commit 4ddae95
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/devise/multi_email/models/validatable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,13 @@ module EmailValidatable

included do
validates_presence_of :email, if: :email_required?
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
if Devise.activerecord51?
validates_uniqueness_of :email, allow_blank: true, case_sensitive: true, if: :will_save_change_to_email?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :will_save_change_to_email?
else
validates_uniqueness_of :email, allow_blank: true, if: :email_changed?
validates_format_of :email, with: email_regexp, allow_blank: true, if: :email_changed?
end
end

def email_required?
Expand Down

0 comments on commit 4ddae95

Please sign in to comment.