Oops. Spoke too soon. While it doesn’t throw a syntax error. only the
last “:scope => x” option is acted upon. So the question remains…
Is there an easy way to accomplish nested scoping?
Thanks much for any advice.
Best regards,
Bill
----- Original Message -----
From: Bill W.
To: [email protected]
Sent: 2006-03-26 1:21 PM
Subject: Re: [Rails] validate_uniqueness_of {combination of fields}
???
I’ll be damned. The nested scoping works just the way I wrote it
below. I’m posting this just so another newbie might be spared the
angst. RoR ROCKS!
----- Original Message -----
From: Bill W.
To: [email protected]
Sent: 2006-03-26 12:47 PM
Subject: Re: [Rails] validate_uniqueness_of {combination of fields}
???
I've realized in rereading my post below that I could have stated
the problem I’m having more clearly. The system is multi-user, so the
record set within which I’m trying to validate_uniqueness_of is
constrained by a third field (e.g., ‘group_id’). So I’m already using
the “scope” option on validates_uniqueness_of. I think what I’m looking
for is nested scoping. Something like:
validates_uniqueness_of :fname, :scope => "lname", :scope =>
“group_id”
Is there an easy (i.e., Rails) way to accomplish this?
Thanks,
Bill
----- Original Message -----
From: Bill W.
To: [email protected]
Sent: 2006-03-26 11:08 AM
Subject: [Rails] validate_uniqueness_of {combination of fields}
???
I've looked at the validates documentation and it appears that
validates_uniqueness_of works on only one field at a time. So I can,
for example, validate that “sam” is unique to the record set, and that
“smith” is unique to the record set.
My problem is that each record includes two fields, the
combination of which must be unique to the record set, but each of
which may not be unique. So “sam smith”, “mary smith” and “sam jones”
(stored as fname, lname) all need to pass the validation.
Is there an easy way to validate_uniqueness_of a combination of
fields within a record?
Thanks in advance for any help.
Best regards,
Bill
_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails