Money
The Money field edits a monetized amount with an optional currency selector and displays a formatted monetary value on index and show pages.
# app/avo/resources/product.rb
field :price, as: :money, currencies: %w[EUR USD RON PEN]Without field-specific options, the currency selector is enabled but its list is empty. The currency column name follows the money-rails currency postfix, normally _currency.
Install the field and monetize the attribute
This field is a standalone gem. You have to add it to your Gemfile alongside the money-rails gem.
Add this field to the Gemfile
# Gemfile
gem "avo-money_field"
gem "money-rails", "~> 1.12"Important: Monetization Requirement
In order to fully utilize the money field's features, you must monetize the associated attribute at the model level using the monetize method from the money-rails gem. (Usage example)
For example:
# app/models/product.rb
monetize :price_centsWithout this step, the money field may not behave as expected, and the field might not render.
Choose the available currencies
Pass currencies to choose the ISO currency codes shown in the dropdown, as in the opening example. Validate allowed currencies on your model if you also need to restrict what can be saved.
Edit the amount without changing the currency
If the currency is managed elsewhere, set enable_currency to false. This hides the selector and leaves the record's currency column untouched when saving the amount.
# app/avo/resources/product.rb
field :price, as: :money, enable_currency: falseUse a different currency column suffix
If your monetized attribute uses a different currency column name, set currency_suffix to match the currency attribute configured on your model. For example, price with "_currency" targets price_currency; "_currency_code" targets price_currency_code.
# app/avo/resources/product.rb
field :price, as: :money, currency_suffix: "_currency"Preview the field in each view
Explore the money field in avodemo and its resource code on GitHub.
Create a record

View a record

Browse records

Configure shared field behavior
For options shared with other fields, see Common field options.