gregbell/active_admin — pull request #1117 by amiel (2012-03-08 19:38:19+00:00)
Title: Support automatic use of decorators

## Background

See discussion at #1079.

Includes brand new shiny specs for `ActiveAdmin::Views::Pages::Index` and `ActiveAdmin::Views::Pages::Show`.

All of this is consistant with the jcasimir/draper api, but does not specifically require draper.
It is also fully backwards compatible for folks that do not use decorators.

## Current functionality

### index

If `#{active_admin_config.resource_class}Decorator` is defined, the view will get
the collection returned by `#{active_admin_config.resource_class}Decorator.decorate(collection)`

Because of the pagination and scoping in ActiveAdmin, this requires that `#decorate` return a
collection proxy and not just an array of decorators. This is the case in jcasimir/draper starting at v0.9.3.

A different decorator class can be passed with the decorator option. Examples

```ruby
index decorator: 'AwesomeDecorator' do; end

index decorator: nil; end # To disable the use of decorators
```

### Show

The show version works a little differently. If the resource object `responds_to?(:decorator)`
then that is what will be used. It would be possible to configure the decorator class the same
way as `Index` for consistency, but for now you can override `#decorator` on the model.