[email protected] wrote:
> Hello
> 
> I have the three database models: "seller", "client" and "account". A
> seller may have many clients and many accounts, but I would like to
> add the constraint that given a seller and a client, only one account
> may exist between them.
> 
> Is there a way to express this contraint using ActiveRecord relations?

Yes -- validates_uniqueness_of will do the trick -- but never rely 
solely on ActiveRecord constraints.  You need a unique index (and 
foreign key constraints) on the DB side too.

> 
> Thanks in advance,
> Andre

Best,
--
Marnen Laibow-Koser
http://www.marnen.org
[email protected]
-- 
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 post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to