Rails - Validate Nested Attributes Uniqueness with scope parent of parent
问题 I have a problem with the scoped uniqueness validation in Rails for nested attributes with a parent of parent. Background I have a rails 4 application with 3 models : #app/models/account.rb class Account < ActiveRecord::Base has_many :contacts, dependent: :destroy end #app/models/contact.rb class Contact < ActiveRecord::Base belongs_to :account has_many :email_addresses, dependent: :destroy, validate: :true, inverse_of: :contact accepts_nested_attributes_for :email_addresses,allow_destroy: