0

I have field

monetize :unit_price_cents, as: 'unit_price', with_model_currency: :unit_price_currency

It's type in database is float. And I want to save value in database keep 6 decimal value. in Money GEM, I custom success:

Money.new(1.123456).to_f => 0.01123456

I debug some func, and think the problem in gem money-rails. It round before calling Money.new

So any config or customize could do that? code loading in gem so crazy

Peter89
  • 706
  • 8
  • 26

2 Answers2

0

I don't fully understand your question. Can you change the database format to decimal(12,6)? This allows for 6 digits BEFORE the decimal point, which should be enough for everybody(tm)

increddibelly
  • 1,221
  • 1
  • 15
  • 25
0

So for allowing to use decimal cents. Just add config to initialize/money.rb

Money.infinite_precision = true

and maybe you want to customize func format of Money gem to show decimal for cent.

Peter89
  • 706
  • 8
  • 26