Matt Jones wrote in post #1109607:
> On Saturday, 18 May 2013 11:14:35 UTC-4, Denny Mueller wrote:
>>> belongs_to :user
>> 1              0001                    1
>> 2              0002                    1
>> 3              0001                    2
>> 4              0001                    3
>> 5              0002                    3
>>
>>
>> How can i approach this? Any hints what I have to look for?
>>
>
> validates_uniqueness_of has a 'scope' option that will do exactly what
> you're describing:

Also note that any use of validates_uniqueness_of should also be backed 
by unique constraints in the database to prevent race conditions from 
causing duplicates.

For more details on race conditions related to uniqueness validations 
read the section under "Concurrency and integrity" here:

http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of

-- 
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 [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/rubyonrails-talk/46b921321ce9e4d0cb821f7270560fe9%40ruby-forum.com?hl=en-US.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to