Suppose the models:
class A < ActiveRecord::Base
has_many :bs
end
class B < ActiveRecord::Base
belongs_to :a
has_many :cs
end
class C < ActiveRecord::Base
belongs_to :b
end
If I want a C attribute to be unique in B's scope I can do this:
class C < ActiveRecord::Base
belongs_to :b
validates :atributo, presence: true,
uniqueness: { case_sensitive: false,
scope: :b_id,
message: 'precisa ser único' }
end
But how do I want it to be unique in the scope of A, since I do not have a_id
in table C?