This project is archived and is in readonly mode.

#4699 open
hello (at convandesign)

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

  • hello (at convandesign)

    hello (at convandesign) May 26th, 2010 @ 05:40 AM

    this is from the beta 3.0 branch....

  • ddelco

    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

    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

    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

    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

    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.

  • Neeraj Singh

    Neeraj Singh June 16th, 2010 @ 06:11 AM

    Did not mean to clear tag. Not sure why tag got cleared.

  • Jeremy Kemper

    Jeremy Kemper October 15th, 2010 @ 11:01 PM

    • Milestone set to 3.0.2
    • Importance changed from “” to “Low”
  • Matt Buck

    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.

  • bingbing
  • Greg Hazel

    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>

Pages