You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
These docs are for ActiveModel, but Money is not a model. At this point so many things rely on the json encoding on Money it would probably break a lot of things if we tried to make Money serialize into an object in JSON land.
We have some leeway between float and string, because people call to_f on it, but making the leap to an object is a big API change.
I believe these methods are also called on attributes of the model being serialized, which via the way of money_column will happen a lot. Not sure of the various subtle differences between what Rails itself and e.g. ActiveModel::Serializer though.
According to the Rails docs:
as_json
should return a hash of attributes (amount, currency) to be serialized, not a stringfrom_json
is missing to assign attributes from a JSON objectWe should not override to_json. A great explanation of the difference between as/to_json can be found here: ohler55/oj#199 (comment)
The text was updated successfully, but these errors were encountered: