Forum: Ruby on Rails Validating uniquesness through double association?

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
on 2007-04-17 16:40
(Received via mailing list)
Hello all!

Could someone give me idea how to solve following problem.

In the model:

class A < ActiveRecord::Base
  has_many :B

class B < ActiveRecord::Base
  belongs_to :A
  has_and_belongs_to_many :C

class C < ActiveRecord::Base
  has_and_belongs_to_many :B

Is it possible to validate that C has only B's that belong to the same
A ? %)

Will be happy to see any answers))
This topic is locked and can not be replied to.