Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class User < ApplicationRecord
- validate :uniqueness_email_and_password
- private
- def uniqueness_email_and_password
- user = User.find_by email: self.email
- return true unless user # Pass validation if the email is available (user = nil)
- !(user.password == self.password) # Returns false if the passwords are the same (fail validation)
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement