Sha256: d51c7abd72c828da57cb144037ae2814a79215f051893cd973c2238bd9d1566b

Contents?: true

Size: 1.23 KB

Versions: 17

Compression:

Stored size: 1.23 KB

Contents

---
title: Customizing attribute partials
---

Occasionally you might want to change how specific types of attributes appear
across all dashboards. You can customize the following built in field types:

- `belongs_to`
- `boolean`
- `date_time`
- `date`
- `email`
- `has_many`
- `has_one`
- `number`
- `polymorphic`
- `select`
- `string`
- `text`

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`

You can generate the partials for all field types by passing `all` to the generator.

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

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

17 entries across 17 versions & 2 rubygems

Version Path
administrate-1.0.0.beta2 docs/customizing_attribute_partials.md
administrate-1.0.0.beta1 docs/customizing_attribute_partials.md
administrate-0.20.1 docs/customizing_attribute_partials.md
administrate-0.20.0 docs/customizing_attribute_partials.md
administrate-0.19.0 docs/customizing_attribute_partials.md
administrate-0.18.0 docs/customizing_attribute_partials.md
administrate-0.17.0 docs/customizing_attribute_partials.md
administrate-0.16.0 docs/customizing_attribute_partials.md
administrate-0.15.0 docs/customizing_attribute_partials.md
administrate-0.14.0 docs/customizing_attribute_partials.md
viniBaxterDesk-22.0.0 docs/customizing_attribute_partials.md
viniBaxterDesk-0.21.0 docs/customizing_attribute_partials.md
viniBaxterDesk-0.20.0 docs/customizing_attribute_partials.md
viniBaxterDesk-0.14.0 docs/customizing_attribute_partials.md
viniBaxterDesk-0.13.2 docs/customizing_attribute_partials.md
viniBaxterDesk-0.13.1 docs/customizing_attribute_partials.md
administrate-0.13.0 docs/customizing_attribute_partials.md