This project is archived and is in readonly mode.
validate_on_create and validate_on_update no longer seem to exist
Reported by Pascal Rettig | February 6th, 2010 @ 04:26 PM
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+. "
Comments and changes to this ticket
- 
            
        

Joe None March 24th, 2010 @ 08:13 PM
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?
 - 
            
        

Jon Atack March 25th, 2010 @ 01:02 AM
validate :method_name, :on => :create
validate :method_name, :on => :update - 
            
        

Jon Atack March 25th, 2010 @ 01:04 AM
Or using your example:
validate :create_validation, :on => :create
 - 
            
        

Jon Atack March 25th, 2010 @ 01:04 AM
Or using your example:
validate :create_validation, :on => :create
 - 
        

José Valim March 26th, 2010 @ 12:15 AM
- State changed from new to invalid
 
Yes, they were removed. Just updated the docs.
 
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>