On Nov 29, 2:11 pm, "Adam French" <[EMAIL PROTECTED]> wrote:
> You can check validity before even attempting the save:
>
> if foo.valid?
>   foo.save
>   # party
> else
>   # handle the validation error
> end
>
> in this regard, you know for sure you're dealing with an invalid
> object and you haven't incurred the 50x slowdown of raising an
> exception.

This runs validation twice every time, which is slow and far worse
IMO, and may also be incorrect.  E.g. if your record validates that it
is at least 24 hours before a certain date, it is possible that the
time will be 12:59:59 when valid is run, and 00:00:00 when save is
run.  That is particularly likely if for some reason the database is
locked and the INSERT/UPDATE is queued.


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"DataMapper" 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/datamapper?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to