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+unsubscr...@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
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.

Reply via email to