No commit activity in last 3 years
No release in over 3 years
Inspired by http://thepugautomatic.com/2014/03/draper/ to not use draper while decorating th
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.7
>= 0
~> 10.0
>= 0

Runtime

>= 4.0.0
 Project Readme

Activeadmin Poro Decorator

Alternative for draper, if you need decorators at ActiveAdmin (and Rails). Active Admin uses the Draper gem for decorators, but sometimes you don't need that. For reasons you could read this article: http://thepugautomatic.com/2014/03/draper.

See discussion of PORO with Active Admin authors here.

Installation

Add this line to your application's Gemfile:

gem 'activeadmin-poro-decorator'

And then execute:

$ bundle

Or install it yourself as:

$ gem install activeadmin-poro-decorator

Then run rake-task to copy config file:

$ rake config:copy

Finally, rename activeadmin-poro-decorator.yml.sample to activeadmin-poro-decorator.yml:

$ mv config/activeadmin-poro-decorator.yml.example config/activeadmin-poro-decorator.yml

Usage

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

  permit_params :title

  index do
    column :id
    column :title
    column :hello       #delegated
    column :link_title  #delegated
  end
end

# app/presenters/post_decorator.rb
class PostDecorator < DelegateClass(Post)
  include ActiveadminPoroDecorator

  def hello
    "Hello, #{title}"
  end

  def link_title
    helpers.link_to(id, url_helpers.admin_post_path(self))
  end
end

For more examples have a look to sample app

Credits

Activeadmin-poro-decorator is created with support of Legelisten.no

Contributing

  1. Fork it ( https://github.com/[my-github-username]/activeadmin-poro-decorator/fork )
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create a new Pull Request