Active Admin
Active Admin Documentation
Active Admin is a framework for creating administration style interfaces. It abstracts common business application patterns to make it simple for developers to implement beautiful and elegant interfaces with very little effort.
# Gemfile in Rails >= 3.1
gem 'activeadmin'
gem 'sass-rails'
gem "meta_search", '>= 1.1.0.pre'
$> rails generate active_admin:install
D:\work\haha>rails g active_admin:install
invoke devise
generate devise:install
create config/initializers/devise.rb
create config/locales/devise.en.yml
===============================================================================
Some setup you must do manually if you haven't yet:
1. Ensure you have defined default url options in your environments files. Here
is an example of default_url_options appropriate for a development environment
in config/environments/development.rb:
config.action_mailer.default_url_options = { :host => 'localhost:3000' }
In production, :host should be set to the actual host of your application.
2. Ensure you have defined root_url to *something* in your config/routes.rb.
For example:
root :to => "home#index"
3. Ensure you have flash messages in app/views/layouts/application.html.erb.
For example:
<p class="notice"><%= notice %></p>
<p class="alert"><%= alert %></p>
4. If you are deploying Rails 3.1 on Heroku, you may want to set:
config.assets.initialize_on_precompile = false
On config/application.rb forcing your application to not access the DB
or load models when precompiling your assets.
===============================================================================
invoke active_record
create db/migrate/20120327045613_devise_create_admin_users.rb
create app/models/admin_user.rb
invoke test_unit
create test/unit/admin_user_test.rb
create test/fixtures/admin_users.yml
insert app/models/admin_user.rb
route devise_for :admin_users
gsub app/models/admin_user.rb
gsub config/routes.rb
insert db/migrate/20120327045613_devise_create_admin_users.rb
create config/initializers/active_admin.rb
create app/admin
create app/admin/dashboards.rb
route ActiveAdmin.routes(self)
generate active_admin:assets
create app/assets/javascripts/active_admin.js
create app/assets/stylesheets/active_admin.css.scss
create db/migrate/20120327125627_create_admin_notes.rb
create db/migrate/20120327125628_move_admin_notes_to_comments.rb
$> rake db:migrate
== DeviseCreateAdminUsers: migrating =========================================
-- create_table(:admin_users)
-> 0.0312s
-- add_index(:admin_users, :email, {:unique=>true})
-> 0.0000s
-- add_index(:admin_users, :reset_password_token, {:unique=>true})
-> 0.0000s
== DeviseCreateAdminUsers: migrated (0.2344s) ================================
== CreateAdminNotes: migrating ===============================================
-- create_table(:admin_notes)
-> 0.0000s
-- add_index(:admin_notes, [:resource_type, :resource_id])
-> 0.0000s
-- add_index(:admin_notes, [:admin_user_type, :admin_user_id])
-> 0.0000s
== CreateAdminNotes: migrated (0.0000s) ======================================
== MoveAdminNotesToComments: migrating =======================================
-- remove_index(:admin_notes, [:admin_user_type, :admin_user_id])
-> 0.0000s
-- rename_table(:admin_notes, :active_admin_comments)
-> 0.0000s
-- rename_column(:active_admin_comments, :admin_user_type, :author_type)
-> 0.0156s
-- rename_column(:active_admin_comments, :admin_user_id, :author_id)
-> 0.0000s
-- add_column(:active_admin_comments, :namespace, :string)
-> 0.0000s
-- add_index(:active_admin_comments, [:namespace])
-> 0.0000s
-- add_index(:active_admin_comments, [:author_type, :author_id])
-> 0.0000s
-- Updating any existing comments to the admin namespace.
-- execute("UPDATE active_admin_comments SET namespace='admin'")
-> 0.0000s
== MoveAdminNotesToComments: migrated (0.0469s) ==============================
$> rails server
Visit http://localhost:3000/admin and log in using:
- User: admin@example.com
- Password: password
Voila! You’re on your brand new Active Admin dashboard.