Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

A Rails admin interface generator. Theme stolen from Redmine. Similar to web-app-theme.

branch: master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 app
Octocat-spinner-32 config
Octocat-spinner-32 doc
Octocat-spinner-32 lib
Octocat-spinner-32 vendor
Octocat-spinner-32 .gitignore
Octocat-spinner-32 .rvmrc
Octocat-spinner-32 Gemfile
Octocat-spinner-32 README.rdoc
Octocat-spinner-32 Rakefile
Octocat-spinner-32 admin_interface.gemspec
README.rdoc

AdminInterface

A Rails admin interface generator for Rails 3.1+. Theme stolen from Redmine. Similar to web-app-theme.

More info

Generator to create some nifty admin scaffolds. It can work with MetaSearch and Kaminari. It also has admin authentication really well implemented.

Install

Rails 3

You should be using v1.2.0+ of the Gem. Add the following to your Gemfile.

gem 'admin_interface'

Usage / Example

Generate the initial framework (layout, etc.)

rails generate admin_interface:setup

This will:

  • Create an Admin::BaseController in app/controllers/admin/base_controller.rb

  • Create a layout in app/views/layouts/admin.html.erb

Change the app/controllers/admin/base_controller.rb to have a before filter only allowing admins to access it.

To view the admin page go to /admin (username: admin, password: admin).

Generate admin models and controllers

Create a scaffold for a model, for example:

rails generate admin_interface:scaffold post
rails generate admin_interface:scaffold post title:string body:text published:boolean
rails generate admin_interface:scaffold purchase order_id:integer amount:decimal

This will:

  • Create stuff similar to original Rails scaffold generator but for admin interface.

  • NOT create model since you probably have it already.

Pass the name of the model (in singular form), either CamelCased or under_scored, as the first argument, and an optional list of attribute pairs.

Attribute pairs are column_name:sql_type arguments specifying the model's attributes. Timestamps are added by default, so you don't have to specify them by hand as 'created_at:datetime updated_at:datetime'.

Customize

You should customize your admin area so it can be more functional and nicely looking.

See it in action

Go to /admin and you can see everything in action.

Screenshot

raw.github.com/joost/admin_interface/master/doc/screenshot.png

Error messages

Add this to a initializer or in your environment.rb (see: railscasts.com/episodes/39-customize-field-error) This will make sure the admin errors will show in correct styling.

# Change the error from div to span
ActionView::Base.field_error_proc = Proc.new do |html_tag, instance_tag|
  "<span class='field_with_errors'>#{html_tag}</span>".html_safe
end

Note that this might affect the rest of your application. A different solution is welcome!

Kudos

Kudos, credits or whatever you like more go to:

  • Jean-Philippe Lang (creator of Redmine).

Copyright © 2012 Joost Hietbrink, released under the MIT license

Something went wrong with that request. Please try again.