diff options
author | Jeremy Kemper <jeremy@bitsweat.net> | 2010-05-17 07:58:26 -0700 |
---|---|---|
committer | Jeremy Kemper <jeremy@bitsweat.net> | 2010-05-17 07:58:26 -0700 |
commit | 5371242384171dc0255716e31e9257ddeec17d10 (patch) | |
tree | d1af041137cee54ff6fc6dd9b7269c7635db644d /activemodel/lib/active_model | |
parent | c2fb8afaa0e6a8f3d1782c97790a4bea8d4f0b0b (diff) | |
download | rails-5371242384171dc0255716e31e9257ddeec17d10.tar.gz rails-5371242384171dc0255716e31e9257ddeec17d10.tar.bz2 rails-5371242384171dc0255716e31e9257ddeec17d10.zip |
Valid hex strings aren't valid float column values, to match the integer restriction. [#4622 state:resolved]
Diffstat (limited to 'activemodel/lib/active_model')
-rw-r--r-- | activemodel/lib/active_model/validations/numericality.rb | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb index 716010e88b..ac8308b0d7 100644 --- a/activemodel/lib/active_model/validations/numericality.rb +++ b/activemodel/lib/active_model/validations/numericality.rb @@ -57,10 +57,15 @@ module ActiveModel protected def parse_raw_value_as_a_number(raw_value) - begin - Kernel.Float(raw_value) - rescue ArgumentError, TypeError + case raw_value + when /\A0x/ nil + else + begin + Kernel.Float(raw_value) + rescue ArgumentError, TypeError + nil + end end end |