RubyMoney / money-rails

Integration of RubyMoney - Money with Rails
MIT License
1.8k stars 387 forks source link

`humanized_money` doesn't respect `config.default_format.no_cents_if_whole` #656

Closed smtlaissezfaire closed 1 year ago

smtlaissezfaire commented 2 years ago

With config setting:

config.default_format = {
  no_cents_if_whole: true,
}

humanized_money doesn't respect the config.default_format.no_cents_if_whole setting.

The code seems to do this:

options = {
  no_cents_if_whole: MoneyRails::Configuration.no_cents_if_whole.nil? ? true : MoneyRails::Configuration.no_cents_if_whole,
  ....
}

A hack is setting config.no_cents_if_whole as well as config.default_format.no_cents_if_whole:

  NO_CENTS_IF_WHOLE = false

  config.no_cents_if_whole = NO_CENTS_IF_WHOLE
  config.default_format = {
    no_cents_if_whole: NO_CENTS_IF_WHOLE,
    symbol: nil,
    sign_before_symbol: nil,
  }

But this seems like a bug.

louiswdavis commented 3 days ago

I also had this issue and this work-around has got it working for me