aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel
diff options
context:
space:
mode:
authorMatthew Draper <matthew@trebex.net>2017-05-28 11:00:07 +0930
committerGitHub <noreply@github.com>2017-05-28 11:00:07 +0930
commit1758292f55d2a938659b47fe19b23ced4881cfad (patch)
tree7b3f766e824c79e57193ea3c6f3060cdb1ba98eb /activemodel
parent94d94d0ac3c1026185805905bcaad8e16e05d0ac (diff)
parentd83b8e65102d625c9024cd9a2727a10b0ef83b79 (diff)
downloadrails-1758292f55d2a938659b47fe19b23ced4881cfad.tar.gz
rails-1758292f55d2a938659b47fe19b23ced4881cfad.tar.bz2
rails-1758292f55d2a938659b47fe19b23ced4881cfad.zip
Merge pull request #29249 from bradleypriest/numericality-precision-regression
Fix regression in Numericality validator
Diffstat (limited to 'activemodel')
-rw-r--r--activemodel/CHANGELOG.md5
-rw-r--r--activemodel/lib/active_model/validations/numericality.rb4
2 files changed, 8 insertions, 1 deletions
diff --git a/activemodel/CHANGELOG.md b/activemodel/CHANGELOG.md
index e707a65147..7483704212 100644
--- a/activemodel/CHANGELOG.md
+++ b/activemodel/CHANGELOG.md
@@ -1,3 +1,8 @@
+* Fix regression in numericality validator when comparing Decimal and Float input
+ values with more scale than the schema.
+
+ *Bradley Priest*
+
* Fix methods `#keys`, `#values` in `ActiveModel::Errors`.
Change `#keys` to only return the keys that don't have empty messages.
diff --git a/activemodel/lib/active_model/validations/numericality.rb b/activemodel/lib/active_model/validations/numericality.rb
index b82c85ddf4..fb053a4c4e 100644
--- a/activemodel/lib/active_model/validations/numericality.rb
+++ b/activemodel/lib/active_model/validations/numericality.rb
@@ -36,7 +36,9 @@ module ActiveModel
return
end
- unless raw_value.is_a?(Numeric)
+ if raw_value.is_a?(Numeric)
+ value = raw_value
+ else
value = parse_raw_value_as_a_number(raw_value)
end