This project is archived and is in readonly mode.

#4804 ✓committed

ActiveRecord.validators broken in 3.0b4

Reported by Ron | June 9th, 2010 @ 07:12 AM | in 3.0.2

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
class Order < ActiveRecord::Base
  validates :name, :presence => true, :length => {:minimum => 3, :maximum => 100}
  validates :price, :numericality => true

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.

Comments and changes to this ticket

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=""></a>


Referenced by