<commit_before># Decorators

Active Admin allows you to use the decorator pattern to provide view-specific
versions of a resource. [Draper](https://github.com/drapergem/draper) is
recommended but not required.

## Example usage

```ruby
# app/models/post.rb
class Post < ActiveRecord::Base
  # has title, content, and image_url
end

# app/decorators/post_decorator.rb
class PostDecorator < ApplicationDecorator
  delegate_all

  def image
    h.image_tag model.image_url
  end
end

# app/admin/post.rb
ActiveAdmin.register Post do
  decorate_with PostDecorator

  index do
    column :title
    column :image
    actions
  end
end
```

## Forms

If you decorate an AA resource, the form will also be docrated.

In most cases this will work as expected, but if your decorator uses the same
method name as an attribute and it returns a modified version of the attribute's
value, you'll want to set `decorate: false` to make sure that the population of
existing values happens correctly:

```ruby
ActiveAdmin.register Post do
  decorate_with PostDecorator

  form decorate: false do
    # ...
  end
end
```<commit_msg>typo fixes<commit_after># Decorators

Active Admin allows you to use the decorator pattern to provide view-specific
versions of a resource. [Draper](https://github.com/drapergem/draper) is
recommended but not required.

## Example usage

```ruby
# app/models/post.rb
class Post < ActiveRecord::Base
  # has title, content, and image_url
end

# app/decorators/post_decorator.rb
class PostDecorator < ApplicationDecorator
  delegate_all

  def image
    h.image_tag model.image_url
  end
end

# app/admin/post.rb
ActiveAdmin.register Post do
  decorate_with PostDecorator

  index do
    column :title
    column :image
    actions
  end
end
```

## Forms

If you decorate an AA resource, the form will also be decorated.

In most cases this will work as expected, but if your decorator uses the same
method name as an attribute and it returns a modified version of the attribute's
value, you'll want to set `decorate: false` to make sure that the population of
existing values happens correctly:

```ruby
ActiveAdmin.register Post do
  decorate_with PostDecorator

  form decorate: false do |f|
    # ...
  end
end
```
{'fraction_non_alphanumeric': 0.06630824372759857, 'fraction_numerical': 0.0, 'mean_word_length': 3.9732739420935412, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6847957', 'n_tokens_mistral': 691, 'n_tokens_neox': 659, 'n_words': 272}