Created
February 13, 2019 02:09
-
-
Save pablomarti/947a1b0554ac71bd270e78d19872fed9 to your computer and use it in GitHub Desktop.
Modifying Rails validator on runtime
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
unique_email_validator = validators_on(:email).find { |v| | |
v.is_a?(ActiveRecord::Validations::UniquenessValidator) | |
} | |
def unique_email_validator.validate(*users) | |
return false if users.map(&:chatbox).all? | |
return false unless app_users?(users.collect(&:email)) | |
super | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment