Forum: Ruby on Rails Validating uniquesness through double association?

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
(Guest)
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
end

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

class C < ActiveRecord::Base
  has_and_belongs_to_many :B
end

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.