I have the following configuration in rails:
Company
has_many :company_products
has_many :products, :through => :company_products
Product
has_many :company_products
has_many :companies, :through => :company_products
ProductGroup
has_many :company_products
CompanyProduct
belongs_to :company
belongs_to :product
belongs_to :product_group
I need to validate whenever I create the Company
or Product
if it contains a CompanyProduct
too.
How can I validate the CompanyProduct
by Company or Product
?