Sha256: 1ac3688da51dd0a21876bb7a463f91e4dc1095f854716e24abd8cd75ce95cd2e
Contents?: true
Size: 463 Bytes
Versions: 14
Compression:
Stored size: 463 Bytes
Contents
class Kithe::Validators::ModelParent < ActiveModel::Validator def validate(record) if record.parent.present? && (record.parent.class <= Kithe::Asset) record.errors[:parent] << 'can not be an Asset instance' end if record.parent.present? && record.class <= Kithe::Collection record.errors[:parent] << 'is invalid for Collection instances' end # TODO avoid recursive parents, maybe using a postgres CTE for efficiency? end end
Version data entries
14 entries across 14 versions & 1 rubygems