when does it validate?

0 views
Skip to first unread message

trung

unread,
Nov 14, 2009, 1:42:57 PM11/14/09
to DataMapper
Coming from ActiveRecord land, I expect both object.save and
object.save! to run validation before hand.

It turned out that only object.save! skipped validation.

I'm guessing dm-validations only override #save method.

Dan Kubb (dkubb)

unread,
Nov 15, 2009, 1:57:12 AM11/15/09
to DataMapper
In DataMapper the convention is that any CRUD-type method ending in an
"!" is considered unsafe, and will skip validations and perform the
changes directly on the datastore. The non-"!" performs the
validations, runs the callbacks, and is the safest approach to use 95%
of the time.

Rather than mirror the ActiveRecord syntax we decided to follow the
Ruby conventions more closely: http://dablog.rubypal.com/2007/8/15/bang-methods-or-danger-will-rubyist

--

Dan
(dkubb)
Reply all
Reply to author
Forward
0 new messages