Skip to content


Default subunit_unit to what was set in the config #78

merged 1 commit into from

3 participants


Damn you americans.


+1 :heart:


how will you handle ?

code snippet

 currency = record.send("currency_for_#{attr}")
 decimal_mark = I18n.t('number.currency.format.separator', default: currency.decimal_mark)
 thousands_separator = I18n.t('number.currency.format.delimiter', default: currency.thousands_separator)
 symbol = I18n.t('number.currency.format.unit', default: currency.symbol)

maybe let the key be

decimal_mark = I18n.t("number.currency-#{currency.iso_code}.format.separator", default: currency.decimal_mark)
RubyMoney member

Some tests would be welcome here :)


@deepak I'm not sure how your comment is relavent to this?


@ollym i had created a PR #75
which is also concerned with supporting other currencies and i found this PR useful

I am using money-rails in a current project and am going through the code.

My commit is not directly relevant to your commit
But wanted to pick @alup and your brain on how will you handle currency_separator and other configs

1. money-rails config is the single source of truth
2. specify currency in I18n config

As i said, it is not directly related to your commit
But i though it was interesting

Did not submit a PR for the same as i am using a custom validator
My input is an BigDecimal not a humanized string

@alup alup merged commit e563f9d into RubyMoney:master

1 check passed

Details default The Travis build passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on Feb 2, 2013
  1. @ollym

    Default subunit_unit to what was set in the config

    ollym committed
    Damn you americans.
This page is out of date. Refresh to see the latest.
Showing with 3 additions and 3 deletions.
  1. +3 −3 lib/money-rails/active_record/monetizable.rb
6 lib/money-rails/active_record/monetizable.rb
@@ -35,12 +35,12 @@ def monetize(field, *args)
# Form target name for the money backed ActiveModel field:
# if a target name is provided then use it
- # if there is a "_cents" suffix then just remove it to create the target name
+ # if there is a "_{column.postfix}" suffix then just remove it to create the target name
# if none of the previous is the case then use a default suffix
if name
name = name.to_s
- elsif subunit_name =~ /_cents$/
- name = subunit_name.sub(/_cents$/, "")
+ elsif subunit_name =~ /#{MoneyRails::Configuration.amount_column[:postfix]}$/
+ name = subunit_name.sub(/#{MoneyRails::Configuration.amount_column[:postfix]}$/, "")
# FIXME: provide a better default
name = [subunit_name, "money"].join("_")
Something went wrong with that request. Please try again.