Skip to content

Instantly share code, notes, and snippets.

@sos4nt
Created October 28, 2016 10:53
Show Gist options
  • Save sos4nt/d46c4753b2d99ea2fef536abda25631e to your computer and use it in GitHub Desktop.
Save sos4nt/d46c4753b2d99ea2fef536abda25631e to your computer and use it in GitHub Desktop.
require 'money'
require 'json'
Money.use_i18n = false
class Money
def to_json(*)
to_s
end
end
h = { foo: Money.new(100) }
#=> {:foo=>#<Money fractional:100 currency:USD>}
puts h.to_json
# {"foo":1.00}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment