Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #3228: allow_nil.diff

File allow_nil.diff, 1.1 kB (added by shawn@garbett.org, 3 years ago)

Patch to allow changing validator default of allow_nil

  • activerecord/lib/active_record/validations.rb

    old new  
    226226        :on => :save, 
    227227        :allow_nil => false, 
    228228        :message => nil 
    229       }.freeze 
     229      } 
    230230 
    231231      ALL_RANGE_OPTIONS = [ :is, :within, :in, :minimum, :maximum ].freeze 
    232232 
     
    351351      # occur (e.g. :if => :allow_validation, or :if => Proc.new { |user| user.signup_step > 2 }).  The 
    352352      # method, proc or string should return or evaluate to a true or false value. 
    353353      def validates_acceptance_of(*attr_names) 
    354         configuration = { :message => ActiveRecord::Errors.default_error_messages[:accepted], :on => :save, :allow_nil => true, :accept => "1"
     354        configuration = { :message => ActiveRecord::Errors.default_error_messages[:accepted], :on => :save, :allow_nil => true, :accept => "1", :allow_nil => false
    355355        configuration.update(attr_names.pop) if attr_names.last.is_a?(Hash) 
    356356 
    357357        attr_accessor *attr_names