aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2005-04-30 14:02:03 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2005-04-30 14:02:03 +0000
commit9f1b57779ff3db4f7ef6bfb9e7d1670972340896 (patch)
treeec87830fcdb7bb9396c52a6f47b5ae1e41b6998b /activerecord/lib
parent537efa36d0d9301ff78eb0cec34d4bafe3ebf2e0 (diff)
downloadrails-9f1b57779ff3db4f7ef6bfb9e7d1670972340896.tar.gz
rails-9f1b57779ff3db4f7ef6bfb9e7d1670972340896.tar.bz2
rails-9f1b57779ff3db4f7ef6bfb9e7d1670972340896.zip
Fixed that validate_length_of lost :on option when :within was specified #1195 [jhosteny@mac.com]
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@1258 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord/lib')
-rwxr-xr-xactiverecord/lib/active_record/validations.rb8
1 files changed, 5 insertions, 3 deletions
diff --git a/activerecord/lib/active_record/validations.rb b/activerecord/lib/active_record/validations.rb
index 9af4010a51..9987c0631d 100755
--- a/activerecord/lib/active_record/validations.rb
+++ b/activerecord/lib/active_record/validations.rb
@@ -373,15 +373,17 @@ module ActiveRecord
option_value = options[range_options.first]
# Declare different validations per option.
-
validity_checks = { :is => "==", :minimum => ">=", :maximum => "<=" }
message_options = { :is => :wrong_length, :minimum => :too_short, :maximum => :too_long }
case option
when :within, :in
raise ArgumentError, ':within must be a Range' unless option_value.is_a?(Range) # '
- validates_length_of attrs, :minimum => option_value.begin, :allow_nil => options[:allow_nil]
- validates_length_of attrs, :maximum => option_value.end, :allow_nil => options[:allow_nil]
+ (options_without_range = options.dup).delete(option)
+ (options_with_minimum = options_without_range.dup).store(:minimum, option_value.begin)
+ validates_length_of attrs, options_with_minimum
+ (options_with_maximum = options_without_range.dup).store(:maximum, option_value.end)
+ validates_length_of attrs, options_with_maximum
when :is, :minimum, :maximum
raise ArgumentError, ":#{option} must be a nonnegative Integer" unless option_value.is_a?(Integer) and option_value >= 0 # '
message = options[:message] || options[message_options[option]]