Skip to content

Commit 6631048

Browse files
authored
Merge pull request #29 from glaucocustodio/main
show how to use rails helpers
2 parents 9dcdf78 + 1559851 commit 6631048

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

docs/2.0/field-options.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -126,6 +126,14 @@ This example snippet will make the `:is_writer` field generate emojis instead of
126126

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

129+
## Formatting with Rails helpers
130+
131+
You can also format using Rails helpers like `number_to_currency` (note that `view_context` is used to access the helper):
132+
133+
```ruby
134+
field :price, as: :number, format_using: -> (value) { view_context.number_to_currency(value) }
135+
```
136+
129137
## Sortable fields
130138

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

0 commit comments

Comments
 (0)