Description

A very simple admin UI. If you need something more fancy look at ActiveScaffold.

Requirements

* formtastic
* kaminari

Rails 3.1 or later.

Requires jQuery.

To Do

Some things are currently hardwired. It assumes you have your controllers below admin/. I.e. admin_users_path.

Installation

$ gem install easy_admin_ui

How to use

In your controller:

class Admin::UsersController < ActionController::Base

easy_admin :per_page => 50,
  :order => 'created_at',
  :page_title => 'Users',
  :columns => ['Login', ['Email', 'my_nowrap_class'], 'Name', 'Created'],
  :show_actions => true,
  :skip_new => true,
  :include => '
     after :create do
       # Stuff you want to do after create.
     end'

end

The model is infered by the make_resourceful plugin which is why we don’t need to specify it here. However, the object(s) returned will be named @item or @items (for :index).

Then you need a partial below users/ named ‘_user.html.erb’:

<%=

table_row(:id => "tr_user_#{user.id}", :class => "#{cyc = cycle("even", "odd")}",
  :cells => [
    user.,
    [user.email, 'my_nowrap_class'],
    date_hm(user.created_at),
  ],
  :actions => [
    admin_edit_link(user),
    admin_delete_link_with_confirmation(user)
  ])

-%>

To add a class to your table cells just pass an array as done with the user.email field in the above example.

You need to provide the _form.html.erb partials yourself.

You can always override the default templates by providing templates yourself.

Callbacks

Index page only:

_index_after_title.html.erb
_index_after_table.html.erb

New/edit pages:

_modify_after_title.html.erb
_modify_after_form.html.erb

If these exist the more specific partials below will not be rendered.

Edit page only:

_edit_after_title.html.erb
_edit_after_form.html.erb

New page only:

_new_after_title.html.erb
_new_after_form.html.erb

Will be included on all actions no matter if other partials were present or not:

_after_title.html.erb
_after.html.erb