How to convert dollars into cents for money gem
There're many currencies type in my database.
suppose I have these 3 items in my database
- amount: 100, currency: NTD
- amount:100, currency: USD
- amount:100, currency: JPY
Then
Money.new(100, :NTD)
, the result will be 1 dollar for NTD, but actually it should be 100 dollars.
As as in USD
However,
Money.new(100, :JPY)
, the result is just 100 dollars
for JPY, it's as my expect.
How could I handle this situation in my case. it's not possible to acquire my user to type 100 for 1 dollar with NTD currency.
In the amount field, I want to only save the number for dollar unit.
However the money gem seems only accepts cents
as its input.
Is there any good practice to solve my problem.