Hi !

2007/2/20, chrisfarms <[EMAIL PROTECTED]>:
> But if the validation was happening first....then there would be no
> need to roll anything back, as the commit would not have started....no
> data would have changed
> ...and...the InvalidRecord error would still get raised as usual ...

You cannot not wrap your validations inside a transaction :)

Imagine the following:

class User < AR::B
  validates_uniqueness_of :login
end

The validation must look at a consistent database.  If two requests
come in at the same time, and request A's validation runs, then gets
interrupted, request B runs and saves, then back to request A, that
would create an invalid record.

I know, I know, ActionPack takes a global lock to prevent this
problem, but if you aren't using ActionPack, you *must* run the
validations inside the transaction.

Hope that helps !
--
François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Core" 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-core?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to