money
money copied to clipboard
Money.from_cents stopped working ?
Hello,
I'm using money via money-rails gem,
# Gemfile.lock
monetize (1.9.4)
money (~> 6.12)
money (6.13.8)
i18n (>= 0.6.4, <= 2)
money-rails (1.14.0)
activesupport (>= 3.0)
monetize (~> 1.9.0)
money (~> 6.13.2)
railties (>= 3.0)
and I can't convert from cents, only dollars,
[52] pry(main)> money = Money.from_cents(1000, "USD")
NoMethodError: undefined method `from_cents' for Money:Class
Did you mean? from_amount
from (pry):54:in `__pry__'
[53] pry(main)> Time.now
=> 2021-07-12 14:11:03.936788 -0700
[62] pry(main)> Money.from_amount 600
=> #<Money fractional:60000 currency:USD>
it would be useful if from_cents worked here, not sure if there is some import/override issue in how money-rails is working, maybe I need to post this over there ?
good stuff in the gem though, thx :)
#from_cents was added in 6.16, but the most recent version of money-rails is pinned to version 6.13.2. I would open an issue on money-rails and ask the maintainers to publish an updated gem.
In the meantime, you can use Money.new as #from_cents is just an alias
irb(main):001:0> Money.new(1000, "USD") == Money.from_amount(10)
=> true