Sha256: d100ff2564520291e20df18f4c63b6dfdfbc83cd60e24f25241e7849db58df6b

Contents?: true

Size: 1.36 KB

Versions: 11

Compression:

Stored size: 1.36 KB

Contents

# Decorators

Active Admin supports the use of decorators for resources. Resources will be
decorated for the index and show blocks. The
[draper](https://github.com/drapergem/draper) gem is recommended but not required
(more on requirements below). Note, that Active Admin works out of the box with
Draper `>= 1.0.0`.

## Configuration

    ActiveAdmin.register Post do
      decorate_with PostDecorator
    end

## Example Usage

This example uses [draper](https://github.com/drapergem/draper).

    # Gemfile
    gem 'draper', '>= 1.0.0'

Assuming a post and a post decorator

    class Post < ActiveRecord::Base; end

    class PostDecorator < ApplicationDecorator
      decorates :post

      def image
        h.image_tag model.image_url
      end
    end

Then the following is possible

    ActiveAdmin.register Post do
      decorate_with PostDecorator

      index do
        column(:title)
        column(:image)
      end

      show do
        attributes_table do
          row(:title)
          row(:image)
        end
      end
    end

## Forms

Note that the resource proveded to form_for also gets decorated.

In most cases this will work as expected. However, it is possible to disable
automatic decoration in the form with the `decorate` option:

    ActiveAdmin.register Post do
      decorate_with PostDecorator

      form decorate: false do
        # ...
      end
    end

Version data entries

11 entries across 11 versions & 2 rubygems

Version Path
activeadmin-0.6.6 docs/11-decorators.md
activeadmin-0.6.5 docs/11-decorators.md
activeadmin-0.6.4 docs/11-decorators.md
yousty-activeadmin-1.0.4.pre docs/11-decorators.md
yousty-activeadmin-1.0.3.pre docs/11-decorators.md
yousty-activeadmin-1.0.2.pre docs/11-decorators.md
activeadmin-0.6.3 docs/11-decorators.md
yousty-activeadmin-1.0.1.pre docs/11-decorators.md
yousty-activeadmin-1.0.0.pre docs/11-decorators.md
activeadmin-0.6.2 docs/11-decorators.md
activeadmin-0.6.1 docs/11-decorators.md