Skip to content
Looking for every option?See the full API reference →

Money ​

The Money field edits a monetized amount with an optional currency selector and displays a formatted monetary value on index and show pages.

ruby
# 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

ruby
# 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:

ruby
# app/models/product.rb
monetize :price_cents

Without 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.

ruby
# app/avo/resources/product.rb
field :price, as: :money, enable_currency: false

Use 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.

ruby
# 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 ​

An Avo create-form card containing a money field: an amount input showing 0.00 beside a currency selector set to USD.

View a record ​

An Avo show-view card using the standard description-list layout: Price RON showing 1,499.00 Lei and Price USD showing $199.00 on separate rows with label left and value right.

Browse records ​

An Avo index table with three columns — ID, Title and Price — where the Price column shows each product's money field formatted as a currency value such as $199.00.

Configure shared field behavior ​

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