mirror of
https://github.com/Growstuff/growstuff.git
synced 2026-03-25 18:22:45 -04:00
8 lines
232 B
Ruby
8 lines
232 B
Ruby
class ApprovedValidator < ActiveModel::EachValidator
|
|
def validate_each(record, attribute, value)
|
|
unless record.crop.try(:approved?)
|
|
record.errors[attribute] << (options[:message] || 'must be approved')
|
|
end
|
|
end
|
|
end
|