aboutsummaryrefslogtreecommitdiffstats
path: root/activemodel/lib/active_model/type/decimal.rb
Commit message (Collapse)AuthorAgeFilesLines
* Apply scale before precision when coercing floats to decimalSean Griffin2016-03-241-2/+10
| | | | | | | | | | | | | | | | Since precision is always larger than scale, it can actually change rounding behavior. Given a precision of 5 and a scale of 3, when you apply the precision of 5 to `1.25047`, the result is `1.2505`, which when the scale is applied would be `1.251` instead of the expected `1.250`. This issue appears to only occur with floats, as scale doesn't apply to other numeric types, and the bigdecimal constructor actually ignores precision entirely when working with strings. There's no way we could handle this for the "unknown object which responds to `to_d`" case, as we can't assume an interface for applying the scale. Fixes #24235
* Require dependencies from stdlib in the Decimal typeSean Griffin2015-09-211-0/+2
| | | | | | | In Active Record, it appears these were either autoloaded, which actually was likely due to test ordering since the method `Float#to_d` wouldn't trigger it. This makes it explicit, and unlikely to fail in the future.
* Move ActiveRecord::Type to ActiveModelKir Shatrov2015-09-211-0/+50
The first step of bringing typecasting to ActiveModel