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