This project is archived and is in readonly mode.
before_validation_on_create and before_validation_on_update doesn't exist
-
hello (at convandesign)
this is from the beta 3.0 branch....
-
ddelco
Any answers on this? activerecord/lib/active_record/callbacks.rb still references
_on_createand_on_updatevalidations in the documentation, but they don't seem to be there anymore. -
Neeraj Singh
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
- Milestone cleared.
- Tag set to activerecord, callbacks, documentation
- State changed from new to resolved
- Assigned user set to Santiago Pastorino
-
David Williams
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
- Tag cleared.
Anyone can make changes to http://github.com/lifo/docrails . So please go ahead and make the necessary changes to the documentation.
-
Neeraj Singh
Did not mean to clear tag. Not sure why tag got cleared.
-
Matt Buck
- 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
- 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_createetc.