Re: [Rails] Re: rescuing ActiveRecord::RecordNotUnique: clever or ugly?

2012-04-04 Thread Colin Law
On 3 April 2012 22:30, Fearless Fool wrote: > Let me redact that previous post...my only excuse is that I hadn't had > my coffee yet! > > If the time to make a DB query (let's call it 1 Unit of time) swamps out > any amount of processing in Ruby, then: > > Approach A (do a SELECT to check for exis

[Rails] Re: rescuing ActiveRecord::RecordNotUnique: clever or ugly?

2012-04-03 Thread Fearless Fool
Let me redact that previous post...my only excuse is that I hadn't had my coffee yet! If the time to make a DB query (let's call it 1 Unit of time) swamps out any amount of processing in Ruby, then: Approach A (do a SELECT to check for existence of the record before attempting an insert) will tak

[Rails] Re: rescuing ActiveRecord::RecordNotUnique: clever or ugly?

2012-04-03 Thread Fearless Fool
Joe V. wrote in post #1053641: > A SQL query takes around 1 ms, possibly more if the db server is on a > different machine. That is way more expensive than rescuing an > exception. Joe: Thanks for the useful data point. Just to make sure my understanding is complete, since any db transaction is

[Rails] Re: rescuing ActiveRecord::RecordNotUnique: clever or ugly?

2012-03-27 Thread Joe V.
Fearless Fool wrote in post #1053062: > Peter Vandenabeele wrote in post #1052874: >> A custom validation on the compound unique key would behave >> similar, always do a SELECT (and suffer from the race condition >> documented in >> > http://api.rubyonrails.org/classes/ActiveRecord/Validations/Clas

[Rails] Re: rescuing ActiveRecord::RecordNotUnique: clever or ugly?

2012-03-24 Thread Fearless Fool
Peter Vandenabeele wrote in post #1052874: > A custom validation on the compound unique key would behave > similar, always do a SELECT (and suffer from the race condition > documented in > http://api.rubyonrails.org/classes/ActiveRecord/Validations/ClassMethods.html#method-i-validates_uniqueness_of