aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/validations
diff options
context:
space:
mode:
authornamusyaka <namusyaka@gmail.com>2017-02-17 22:15:01 +0900
committernamusyaka <namusyaka@gmail.com>2017-02-18 19:04:48 +0900
commitb0be7792adf58e092b7f615ecbf3339ea70ee689 (patch)
tree910c19f520e71fd5109a211a509252dfad36917f /activemodel/lib/active_model/validations
parent74689fda0ce7612d87c620a36097d2d7451f53c0 (diff)
downloadrails-b0be7792adf58e092b7f615ecbf3339ea70ee689.tar.gz
rails-b0be7792adf58e092b7f615ecbf3339ea70ee689.tar.bz2
rails-b0be7792adf58e092b7f615ecbf3339ea70ee689.zip
Avoid converting integer as a string into float
Diffstat (limited to 'activemodel/lib/active_model/validations')
-rw-r--r--activemodel/lib/active_model/validations/numericality.rb1
1 files changed, 1 insertions, 0 deletions
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb
index 30a9ef472d..995b331245 100644
--- a/activemodel/lib/active_model/validations/numericality.rb
+++ b/activemodel/lib/active_model/validations/numericality.rb
@@ -70,6 +70,7 @@ module ActiveModel
end
def parse_raw_value_as_a_number(raw_value)
+ return raw_value.to_i if is_integer?(raw_value)
Kernel.Float(raw_value) if raw_value !~ /\A0[xX]/
end