Growstuff/growstuff

View on GitHub
app/validators/approved_validator.rb

Summary

Maintainability
A
0 mins
Test Coverage
# frozen_string_literal: true

class ApprovedValidator < ActiveModel::EachValidator
  def validate_each(record, attribute, _value)
    record.errors.add(attribute, options[:message] || 'must be approved') unless record.crop.try(:approved?)
  end
end