Ruby Weekly is a weekly newsletter covering the latest Ruby and Rails news.

AutoAdmin: Auto-generated admin interface in a Rails plugin

By Peter Cooper / August 17, 2006

Autoadmin

AutoAdmin is a new plugin for Rails that automatically generates an administration interface for your models. It's heavily inspired by Django, where meta-data relating to the administration interface is placed directly into the models. This goes directly against David Heinemeier Hansson's preferences, but might be perfect for your own systems.

Example model code:

class Customer < ActiveRecord::Base
  belongs_to :store
  has_many :payments, :order => 'payment_date DESC'

  def name; first_name + ' ' + last_name; end

  sort_by :last_name
  search_by :first_name, :last_name
  filter_by :active, :store
  default_filter :active => true
  list_columns :store, :first_name, :last_name

  admin_fieldset do |b|
    b.text_field :first_name
    b.text_field :last_name
    b.select :store
  end
  admin_child_table 'Payments', :payments do |b|
    b.static_text :payment_date
    b.static_text :amount
  end
end

Comments

  1. Mike Blair says:

    Cool, the admin interface was by far the best part of Django.

  2. Jeff says:

    Thanks, I was looking for a write up of this earlier today, but couldn't find one. Finding this in my feed agg hit the spot.

  3. Christoffer Sawicki says:

    Another project with similar scope: http://streamlined.relevancellc.com/

Other Posts to Enjoy

Twitter Mentions