Sha256: f01e7a558f0ea40c6614c17d5062b1ff6e805842c742c232231ce736e1cebe2c

Contents?: true

Size: 908 Bytes

Versions: 5

Compression:

Stored size: 908 Bytes

Contents

# Customizing attribute partials

Occasionally you might want to change how specific types of attributes appear
across all dashboards.
For example, you might want all `Number` values to round to three decimal points.

To get started, run the appropriate rails generator:

```bash
rails generate administrate:views:field number
```

This will generate three files:

- `app/view/fields/number/_form.html.erb`
- `app/view/fields/number/_index.html.erb`
- `app/view/fields/number/_show.html.erb`

The generated templates will have documentation
describing which variables are in scope.
The rendering part of the partial will look like:

```eruby
<%= field.data %>
```

Changing numbers to display to three decimal places might look like this:

```eruby
<%= field.data.round(3) %>
```

If you only want to change how an attribute appears
on a single page (e.g. `index`), you may delete the unnecessary templates.

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
administrate-0.8.1 docs/customizing_attribute_partials.md
administrate-0.8.0 docs/customizing_attribute_partials.md
administrate-0.7.0 docs/customizing_attribute_partials.md
administrate-0.6.0 docs/customizing_attribute_partials.md
administrate-0.5.0 docs/customizing_attribute_partials.md