Class: SimplyStored::Couch::Validations::ValidatesUniquenessOf
- Inherits:
-
Validatable::ValidationBase
- Object
- Validatable::ValidationBase
- SimplyStored::Couch::Validations::ValidatesUniquenessOf
- Defined in:
- lib/simply_stored/couch/validations.rb
Instance Method Summary collapse
Instance Method Details
#i18n ⇒ Object
58 59 60 |
# File 'lib/simply_stored/couch/validations.rb', line 58 def i18n super || "#{i18n_prefix}.not_unique" end |
#message(instance) ⇒ Object
54 55 56 |
# File 'lib/simply_stored/couch/validations.rb', line 54 def (instance) super || "#{attribute.to_s.try(:humanize) || attribute.to_s} is already taken" end |
#valid?(instance) ⇒ Boolean
44 45 46 47 48 49 50 51 52 |
# File 'lib/simply_stored/couch/validations.rb', line 44 def valid?(instance) other_instance = instance.class.send("find_by_#{attribute}", instance.send(attribute)) if other_instance && other_instance != instance && other_instance.send(attribute) == instance.send(attribute) false else true end end |