A have two models, \"shop\" and \"product\", linked via has_many :through.
In the shop form there are nested attributes for multiple products, and I\'m having a litt
You could write a custom validator like
# app/validators/products_name_uniqueness_validator.rb
class ProductsNameUniquenessValidator < ActiveModel::EachValidator
def validate_each(record, attribute, value)
record.errors[attribute] << "Products names must be unique" unless value.map(&:name).uniq.size == value.size
end
end
# app/models/shop.rb
class Shop < ActiveRecord::Base
validates :products, :products_name_uniqueness => true
end