Sha256: 01db836dd5ccd0fb9ac30b3c4dbce83154751fe08d490c7fb7d6369dfe420f8d
Contents?: true
Size: 507 Bytes
Versions: 18
Compression:
Stored size: 507 Bytes
Contents
class Kithe::Validators::ModelParent < ActiveModel::Validator def validate(record) # don't load the parent just to validate it if it hasn't even changed. return unless record.parent_id_changed? 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 end end
Version data entries
18 entries across 18 versions & 1 rubygems