Skip to content

Commit

Permalink
show how to use rails helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
glaucocustodio committed Mar 20, 2023
1 parent 9dcdf78 commit 1559851
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions docs/2.0/field-options.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,14 @@ This example snippet will make the `:is_writer` field generate emojis instead of

<img :src="('/assets/img/fields-reference/fields-formatter.jpg')" alt="Fields formatter" class="border mb-4" />

## Formatting with Rails helpers

You can also format using Rails helpers like `number_to_currency` (note that `view_context` is used to access the helper):

```ruby
field :price, as: :number, format_using: -> (value) { view_context.number_to_currency(value) }
```

## Sortable fields

One of the most common operations with database records is sorting the records by one of your fields. For that, Avo makes it easy using the `sortable` option.
Expand Down

0 comments on commit 1559851

Please sign in to comment.