Skip to content

How to work with draper

amiel edited this page Jun 5, 2012 · 3 revisions

Coming Soon

This feature is not yet available in Active Admin, it is still under process in #1117, and still needs testing (hint, hint).

Example Usage with Draper

Add draper to the Gemfile.

# Gemfile
gem 'draper'

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
Clone this wiki locally