This project is archived and is in readonly mode.
before_validation_on_create and before_validation_on_update doesn't exist
Reported by hello (at convandesign) | May 26th, 2010 @ 05:39 AM | in 3.0.2
It seems that those two callbacks have been removed from the activerecords callbacks. Have they've been replaced some how? I've looked into the source code and couldn't figure it out.
Comments and changes to this ticket
-
ddelco June 6th, 2010 @ 01:37 AM
Any answers on this? activerecord/lib/active_record/callbacks.rb still references
_on_create
and_on_update
validations in the documentation, but they don't seem to be there anymore. -
Neeraj Singh June 7th, 2010 @ 09:56 PM
before_validation_on_create and before_validation_on_update methods are available. The syntax has changed.
before_validation(:on => :create){ do_something } before_validation(:on => :update){ do_something }
Yes the documentation needs to be updated.
-
Santiago Pastorino June 8th, 2010 @ 02:35 AM
- Milestone cleared.
- Tag set to activerecord, callbacks, documentation
- State changed from new to resolved
- Assigned user set to Santiago Pastorino
-
David Williams June 16th, 2010 @ 02:42 AM
It's not completely resolved. The paragraph directly above the committed change also needs work. It currently says:
"That’s a total of ten callbacks, which gives you immense power to react and prepare for each state in the Active Record lifecycle. The sequence for calling Base#save for an existing record is similar, except that each on_create callback is replaced by the corresponding on_update callback."
Except that this is the first mention of on_create and on_update, and they don't actually exist anymore. More information would be useful. For instance, is it possible to use the ":on" option and also pass a symbol, or is the block form the only one supported?
-
Neeraj Singh June 16th, 2010 @ 05:03 AM
- Tag cleared.
Anyone can make changes to http://github.com/lifo/docrails . So please go ahead and make the necessary changes to the documentation.
-
Jeremy Kemper October 15th, 2010 @ 11:01 PM
- Milestone set to 3.0.2
- Importance changed from to Low
-
Matt Buck February 8th, 2011 @ 07:49 PM
- Tag set to documentation
Looks like David's comment above was resolved by https://github.com/lifo/docrails/commit/5a6f651a6a093f69f00fa713648...
I'm looking at clarifying this documentation a bit, but I'm confused by the new callback system. The documentation still refers to overriding methods like
before_destroy
, but the examples look like these methods are now meant to be invoked rather than overridden. If somebody can point me in the right direction, I'll commit a fix. -
Greg Hazel March 31st, 2011 @ 01:10 AM
- State changed from resolved to open
I also could use some clarification on the documentation. Is this form allowed?
before_validation :do_something, :on => :create
[state:open]
As a side note, it would make upgrading from Rails 2 to Rails 3 easier if this were more clearly documented or simply backwards compatible with Rails 2 applications using
before_validation_on_create
etc.
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>