class CamaleonCms::PostUniqValidator < ActiveModel::Validator def validate(record) unless record.draft? slug_array = record.slug.to_s.translations_array ptype = record.post_type if ptype.present? # only for posts that belongs to a post type model posts = ptype.site.posts .where("(#{slug_array.map {|s| "#{CamaleonCms::Post.table_name}.slug LIKE '%-->#{s}