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.

This project is archived and is in readonly mode.

ActiveRecord.validators broken in 3.0b4

#4804

Create a new rails app. Add two models each with validations (called say User and Order).

class User < ActiveRecord::Base
  validates :login, :presence => true, :length => {:minimum => 3, :maximum => 10}, :uniqueness => true
  validates :password, :presence => true, :confirmation => true
end
class Order < ActiveRecord::Base
  validates :name, :presence => true, :length => {:minimum => 3, :maximum => 100}
  validates :price, :numericality => true
end

In rails console,

ruby-head > User.validators.size
 => 5 
ruby-head > Order.validators.size
 => 8 
ruby-head > User.validators.size
 => 8 
ruby-head > User.validators_on(:price)
 => [#<ActiveModel::Validations::NumericalityValidator:0x00000106abc230 @attributes=[:price], @options={:only_integer=>false, :allow_nil=>false}>]
It seems that all validators are being added to some single global cache instead of a per model cache.

Reported by Ron · June 9th, 2010 @ 07:12 AM

State: committed
Milestone: 3.0.2
Assigned to: Michael Koziarski Michael Koziarski
Importance: none

Activity

  1. DHH
    DHH
    • Milestone cleared.
    • State changed from new to open
    • Assigned user set to Michael Koziarski

    June 9th, 2010 @ 05:15 PM

  2. Neeraj Singh
    Neeraj Singh
    • Tag set to 3.x, activerecord, patch

    Attaching a patch with test.

    June 10th, 2010 @ 04:11 AM

  3. Repository
    Repository
    • State changed from open to resolved

    June 10th, 2010 @ 04:51 PM

  4. Repository
    Repository
    • State changed from resolved to committed

    June 10th, 2010 @ 04:51 PM

  5. Repository
    Repository

    (from [d67549306567b219089f2355fe432d31d0ebf8a1]) Revert "Validators should at model level and not at AR:Base level [Closes #4804 ActiveRecord.validators broken in 3.0b4]"

    This reverts commit e11bb95d56ed77b10d54d9dfe5a3cc4aa48b3a61.
    http://github.com/rails/rails/commit/d67549306567b219089f2355fe432d...

    June 13th, 2010 @ 02:47 AM

  6. Repository
    Repository

    (from [a087bc85fd24e7261ce6a6f63ffa2dbd49db567d]) Revert "Revert "Validators should at model level and not at AR:Base level [Closes #4804 ActiveRecord.validators broken in 3.0b4]""

    This reverts commit d67549306567b219089f2355fe432d31d0ebf8a1.
    http://github.com/rails/rails/commit/a087bc85fd24e7261ce6a6f63ffa2d...

    June 13th, 2010 @ 02:48 AM

  7. Jeremy Kemper