lib/active_model/validations/numericality.rb in activemodel-3.0.20 vs lib/active_model/validations/numericality.rb in activemodel-3.1.0.beta1

- old
+ new

@@ -22,11 +22,11 @@ end def validate_each(record, attr_name, value) before_type_cast = "#{attr_name}_before_type_cast" - raw_value = record.send("#{attr_name}_before_type_cast") if record.respond_to?(before_type_cast.to_sym) + raw_value = record.send(before_type_cast) if record.respond_to?(before_type_cast.to_sym) raw_value ||= value return if options[:allow_nil] && raw_value.nil? unless value = parse_raw_value_as_a_number(raw_value) @@ -91,10 +91,12 @@ # validates_numericality_of :value, :on => :create # end # # Configuration options: # * <tt>:message</tt> - A custom error message (default is: "is not a number"). - # * <tt>:on</tt> - Specifies when this validation is active (default is <tt>:save</tt>, other options <tt>:create</tt>, <tt>:update</tt>). + # * <tt>:on</tt> - Specifies when this validation is active. Runs in all + # validation contexts by default (+nil+), other options are <tt>:create</tt> + # and <tt>:update</tt>. # * <tt>:only_integer</tt> - Specifies whether the value has to be an integer, e.g. an integral value (default is +false+). # * <tt>:allow_nil</tt> - Skip validation if attribute is +nil+ (default is +false+). Notice that for fixnum and float columns empty strings are converted to +nil+. # * <tt>:greater_than</tt> - Specifies the value must be greater than the supplied value. # * <tt>:greater_than_or_equal_to</tt> - Specifies the value must be greater than or equal the supplied value. # * <tt>:equal_to</tt> - Specifies the value must be equal to the supplied value.