3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
# File 'lib/spree_mobility/core_ext/spree/taxonomy_decorator.rb', line 3
def name_uniqueness_validation
return unless name.present?
return unless translated_model
check_scope =
::Spree::Taxonomy.
where.not(id: translated_model.id).
where(store_id: translated_model.store_id).
joins(:translations).
where(spree_taxonomy_translations: { locale: locale }).
where('LOWER(spree_taxonomy_translations.name) = ?', name.downcase)
if check_scope.exists?
errors.add(:name, :taken, value: name)
end
end
|