Created
December 14, 2016 20:02
-
-
Save hugoerg56/cb2ccb2d4aa8945fd53051e8ec4f4023 to your computer and use it in GitHub Desktop.
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
list_of_valid_states = ["Alava", "Albacete"....] | |
class OptionsValidator < ActiveModel::Validator | |
def validate(record) | |
unless list_of_valid_states.include?(record.state) | |
record.errors[:state] << 'This is not a valid state!' | |
end | |
end | |
end | |
class MiModelo | |
include ActiveModel::Validations | |
validates_with OptionsValidator | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment