Sunday, July 17, 2011

ActiveAdmin Tutorial

What is ActiveAdmin?
Active Admin is a Ruby on Rails plugin for generating administration sytle interfaces. The goals of this plugin are easy-to-use for non-techical users and fast for developers.



How To Use ActiveAdmin
Suppose we are create Blog web application.
$> rails new blog

Add the following to your Gemfile.
# Gemfile
gem 'activeadmin'

Run bundle install.
$> bundle install

Install ActiveAdmin.
$> rails generate active_admin:install

After installation is finished, it will create:
1. An configuration file on config/initializers/active_admin.rb
2. AdminUser model on app/models/admin_user.rb
3. An directory called app/admin to configure the admin interface of our resource.
4. Migration files.

Migrate your db and start the server.
$> rake db:migrate
$> rails server

Visit http://localhost:3000/admin and log in using:
  • Email: [email protected]
  • Password: password

Next, create Post model.
$> rails g model Post title:string content:text

Create admin interface for Post model. Because we use ActiveAdmin, we don't need to create controller for Post model. This generator will create file on app/admin/posts.rb.
$> rails generate active_admin:resource Post

Configure admin interface index page for Post model.
ActiveAdmin.register Post do
  index do
    column :title
    column :content
  end
end

Visit http://localhost:3000/admin/posts to see the result.

More information about ActiveAdmin:


3 comments:

  1. aussum.. i am sure this will help..!

    ReplyDelete
  2. What is on this post that isn't on the github page besides your google adwords?

    ReplyDelete
  3. hmm.. I couldn't install the activeadmin from your tutorial.
    when I've succeded install the activeadmin
    but when I tried this command "rails generate active admin:install"
    an error message come up, it said "Could not find generator active."

    ReplyDelete

Popular Posts