On Jun 12, 4:54 am, Michael Schuerig <[email protected]> wrote:
> On Friday 12 June 2009, Nick Hoffman wrote:
>
> > On Thu, Jun 11, 2009 at 11:24 PM, Ashwin
>
> > Mangale<[email protected]> wrote:
> > > Try commenting out the uniqueness constraint and check the result.
> > > To be fair, the validations listed are fairly standard and can be
> > > done before the keyword object is created ( client-side using
> > > something like ajax + jquery ).
>
> > > Hope this helps.
>
> > > -Ashwin
>
> > Hi Ashwin. I'm finding that the uniqueness constraint doesn't add
> > much additional processing time.
>
> It's a bogus constraint, however, because...
>
> > You're right that the validations are quite standard. However, you
> > can't rely on input data; it must be validated server-side.
>
> it checks uniqueness in the wrong place. validates_uniqueness_of does
> not preclude an interleaving of operations of operations from two
> processes that looks like this
>
>           A                            B
>   create(:keyword => 'foo')
>   validate uniqueness
>                                create(:keyword => 'foo')
>                                validate uniqueness
>                                save
>   save
>
> To be safe, you must have a constraint in the database. If you have
> that, the additional app-level validation just wastes performance.
>
>   add_index :keywords, :keyword, :unique => true
>
> Michael
>
> --
> Michael Schuerig
> mailto:[email protected]://www.schuerig.de/michael/

Are you sure about that?:
http://pastie.org/509569
--~--~---------~--~----~------------~-------~--~----~
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