Money API
Per-option reference for the Money field. For installation and worked examples, see the Money guide.
Options are passed to the field declaration in app/avo/resources/product.rb:
ruby
field :price, as: :money, currencies: %w[EUR USD RON PEN]Currency selection
-> currencies
The choices shown in the currency dropdown. The record's current currency determines the selected choice.
ruby
field :price, as: :money, currencies: %w[EUR USD RON PEN]- Type: Array of Strings (ISO currency codes).
- Default:
[](no choices). - Validation: No field-level currency-code or inclusion validation. Choices are passed to Rails'
options_for_select; the dropdown is not a model validation.
-> enable_currency
Controls whether the currency selector is rendered and whether saving the field assigns the submitted currency to the record. When disabled, only the amount is assigned; the currency column is left untouched.
ruby
field :price, as: :money, enable_currency: false- Type: Boolean.
- Default:
true. - Values:
trueorfalse.niland non-Boolean values fall back totrue.
Currency storage
-> currency_suffix
The suffix appended to the field ID to form the currency attribute name. For price, "_currency" targets price_currency. This name is used by the selector and by currency assignment when saving.
ruby
field :price, as: :money, currency_suffix: "_currency_code"- Type: String or Symbol.
- Default:
MoneyRails::Configuration.currency_column[:postfix]whenMoneyRailsis defined (normally"_currency"); otherwise:_currency. - Validation: No field-level suffix validation. The generated attribute name must match the model's currency attribute; enabling currency assignment requires its setter.
Common field options
For inherited configuration, see Common field options.