如果您在 /config/currency_iso.json 中查看货币 gem
{
"Jpy": {
"priority": 6,
"iso_code": "JPY",
"name": "Japanese Yen",
"symbol": "¥",
"alternate_symbols": ["円", "圓"],
"subunit": null,
"subunit_to_unit": 1,
"symbol_first": true,
"html_entity": "¥",
"decimal_mark": ".",
"thousands_separator": ",",
"iso_numeric": "392",
"smallest_denomination": 1
}
}
你会看到
"subunit_to_unit": 1
所以在这种情况下,你应该用
"subunit_to_unit": 100
这是我在 /config/initializers/money.rb 下的示例代码
Money::Currency.register({
"priority": 6,
"iso_code": "JPY",
"name": "Japanese Yen",
"symbol": "¥",
"alternate_symbols": ["円", "圓"],
"subunit": "Sen",
"subunit_to_unit": 100,
"symbol_first": true,
"html_entity": "¥",
"decimal_mark": ".",
"thousands_separator": ",",
"iso_numeric": "392",
"smallest_denomination": 1
})
您可以在此处添加更多货币。希望这对您有所帮助。