Sha256: f2807856a6804690af98d7ae0742db9a55b4174cf2d4e4f0dc3a730af80bada3
Contents?: true
Size: 467 Bytes
Versions: 2
Compression:
Stored size: 467 Bytes
Contents
class Kithe::Validators::ModelParent < ActiveModel::Validator def validate(record) if record.parent.present? && (record.parent.class <= Kithe::Asset) record.errors.add(:parent, 'can not be an Asset instance') end if record.parent.present? && record.class <= Kithe::Collection record.errors.add(:parent, 'is invalid for Collection instances') end # TODO avoid recursive parents, maybe using a postgres CTE for efficiency? end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kithe-2.2.0 | app/models/kithe/validators/model_parent.rb |
kithe-2.1.0 | app/models/kithe/validators/model_parent.rb |