Class: UserComment::AuthorValidator
- Inherits:
-
ActiveModel::EachValidator
- Object
- ActiveModel::EachValidator
- UserComment::AuthorValidator
- Defined in:
- app/models/user_comment.rb
Instance Method Summary collapse
Instance Method Details
#validate_each(record, attribute, value) ⇒ Object
44 45 46 47 48 49 50 51 52 53 |
# File 'app/models/user_comment.rb', line 44 def validate_each(record, attribute, value) existing = nil if record.vintage existing = vintage.user_comments.find_by(winewoo_user_id: value) if existing record.errors[attribute] << [:message] || 'has already posted a comment.' end end return existing ? false : true end |