Advertisement
Guest User

Untitled

a guest
Jul 15th, 2017
363
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 0.36 KB | None | 0 0
  1. class User < ApplicationRecord
  2.   validate :uniqueness_email_and_password
  3.  
  4.   private
  5.   def uniqueness_email_and_password
  6.     user = User.find_by email: self.email
  7.     return true unless user # Pass validation if the email is available (user = nil)
  8.     !(user.password == self.password) # Returns false if the passwords are the same (fail validation)
  9.   end
  10. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement