I have 3 models, say A, B and C, and they are set up like this:
A:
has_many :Bs
has_many :Cs, through: B
B:
belongs_to A:
has_many :Cs
C:
belongs_to B:
In my model for C, I want to declare, that a column ccol within C must
be unique, but only within the scope of a certain A.
If the constraint would require uniqueness within a certain B, I could
write
validates :ccol, uniqueness: { scope: :B_id }
But since C doesn't contain an A_id as foreign key, I can not express it
in this way.
Is there a possibility to achieve this?
Ronald
--
Posted via http://www.ruby-forum.com/.
--
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to
rubyonrails-talk+unsubscribe-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFF+G/Ez6ZCGd0@public.gmane.org
To view this discussion on the web visit
https://groups.google.com/d/msgid/rubyonrails-talk/1c92cfe04af45f69073d2ead29cb3d22%40ruby-forum.com.
For more options, visit https://groups.google.com/d/optout.