Sha256: fcd7ca7ddb28a1260d3877729a99708c2d2303162acacf1103d313bc9f284cab
Contents?: true
Size: 524 Bytes
Versions: 6
Compression:
Stored size: 524 Bytes
Contents
module CamaleonCms class UniqValidator < ActiveModel::Validator def validate(record) return if record.skip_slug_validation? if CamaleonCms::TermTaxonomy.where(slug: record.slug).where.not(id: record.id).where("#{CamaleonCms::TermTaxonomy.table_name}.taxonomy" => record.taxonomy).where("#{CamaleonCms::TermTaxonomy.table_name}.parent_id" => record.parent_id).size.positive? record.errors[:base] << I18n.t('camaleon_cms.admin.post.message.requires_different_slug').to_s end end end end
Version data entries
6 entries across 6 versions & 1 rubygems