Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

validate_on_create and validate_on_update no longer seem to exist

#3880

ActiveRecord::Base class methods validate_on_create and validate_on_update no longer seem to exist:

$ rails test_app
$ cd test_app
$ rails migration model TestModel
$ rake db:migrate
$ vi app/models/test_model.rb

    class TestModel < ActiveRecord::Base
        validate_on_create :create_validation

        def create_validation
           # Dummy validation
        end
    end

$ rails console

    Loading development environment (Rails 3.0.0.beta)
    irb(main):001:0> TestModel
    NoMethodError: undefined method `validate_on_create' for #<Class:0x7f7f6ad7f5c8>
from /var/lib/gems/1.8/gems/activerecord-3.0.0.beta/lib/active_record/base.rb:1300:in `method_missing'
from /home/pascal/test_app/app/models/test_model.rb:3
from /var/lib/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:396:in `load_without_new_constant_marking'
from /var/lib/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:396:in `load_file'
from /var/lib/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:537:in `new_constants_in'
from /var/lib/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:395:in `load_file'
from /var/lib/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:275:in `require_or_load'
from /var/lib/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:441:in `load_missing_constant'
from /var/lib/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:91:in `const_missing'
from /var/lib/gems/1.8/gems/activesupport-3.0.0.beta/lib/active_support/dependencies.rb:103:in `const_missing'

Not sure if they are supposed to exist anymore, but the rdoc documentation still refers to them:

(From gem server) http://localhost:8808/doc_root/activemodel-3.0.0.beta/rdoc/ActiveMo...

"This usage applies to validate_on_create and +validate_on_update as well+. "

Reported by Pascal Rettig · February 6th, 2010 @ 04:26 PM

State: invalid
Milestone: none
Assigned to: nobody
Importance: Low

Activity

  1. Joe None
    Joe None

    Having the same issue, however I can't find anything that mentions it being taken out/changed. Is there a new way to do the same thing?

    March 24th, 2010 @ 08:13 PM

  2. Jon Atack
    Jon Atack

    validate :method_name, :on => :create
    validate :method_name, :on => :update

    March 25th, 2010 @ 01:02 AM

  3. Jon Atack
    Jon Atack

    Or using your example:

    validate :create_validation, :on => :create

    March 25th, 2010 @ 01:04 AM

  4. Jon Atack
    Jon Atack

    Or using your example:

    validate :create_validation, :on => :create

    March 25th, 2010 @ 01:04 AM

  5. José Valim
    José Valim
    • State changed from new to invalid

    Yes, they were removed. Just updated the docs.

    March 26th, 2010 @ 12:15 AM