33

I had a good time playing with Active Admin the administrative framework within my application. http://activeadmin.info/

When I installed it I ran

rails g active_admin:install
rake db:migrate
rails g active_admin:resource product

and it generated alot of migrations and code within my application.

My question if I would like to go back and have everything that active_admin put into my application taken out, how would i do so?

Is there one 'rails active_admin:uninstall' command to get rid of everything or do I have to manually create migrations to delete all the tables and search through my code to see what it added?

Andrew Grimm
  • 78,473
  • 57
  • 200
  • 338
ChrisWesAllen
  • 4,935
  • 18
  • 58
  • 83

3 Answers3

44

If you run the following code it should destroy active admin:

rails destroy active_admin:install
rails destroy active_admin:resource product
tomciopp
  • 2,602
  • 2
  • 31
  • 60
  • 3
    You don't even need the second line it seems. – David Tuite Dec 13 '11 at 07:22
  • 1
    Also, keep in mid that if you set up an `AdminUser` model when you added ActiveAdmin, this will destroy it, along with any methods you added to it. – David Tuite Dec 13 '11 at 07:35
  • 4
    Beware that some trash code will be left in 'routes.rb' and 'schema.rb'. Do a search for 'admin' and comment the unnecessary code, or it may cause errors later. – chech Jun 05 '13 at 15:28
  • 3
    do i need to rollback the migration – lngs Sep 30 '13 at 12:02
  • Also remove `gem 'activeadmin'` from your gem file or it will install again next time you bundle = ] – rii Aug 18 '15 at 04:08
29

Run this in terminal

rails destroy active_admin:install

Remove gem 'activeadmin' from your gemfile.

Delete the asset files from js and css folders if any remain

Delete any of these lines in Routes.rb

  devise_for :admin_users, ActiveAdmin::Devise.config
  ActiveAdmin.routes(self)
  ActiveAdmin.routes(self)

Then create a new migration with:

  drop_table :active_admin_comments

You may also need:

  drop_table :admin_notes

Or rollback the migrations by finding the relevant files MoveAdminNotesToComments and CreateAdminNotes in your db/migrate folder

rake db:migrate:down VERSION=the_version_number
rake db:migrate:down VERSION=the_version_number
Arunabh Das
  • 13,212
  • 21
  • 86
  • 109
Abram
  • 39,950
  • 26
  • 134
  • 184
  • 1
    The new drop migration is much cleaner than the rollback one, but thanks for making this good answer, everything is in here ;) – gfd Feb 06 '15 at 21:16
  • 1
    For everyone ease, I did : `rails generate migration drop_active_admin_comments` modified the migration like this: `` class DropActiveAdminComments < ActiveRecord::Migration def up drop_table :active_admin_comments end def down raise ActiveRecord::IrreversibleMigration end end `` `` bundle exec rake db:migrate `` the table and indexes are gone ;) – gfd Feb 06 '15 at 21:30
  • Ok, I just don't know how to format a comment with code in it... so I've finally been rejected the right to reedit my previous comment :/ – gfd Feb 06 '15 at 21:37
  • 2
    Oh and don't forget to remove the `gem 'active_admin' ` entry in your Gemfile once the `rails destroy active_admin:install` is done ;) – gfd Feb 06 '15 at 21:39
  • Yes. Thank you I have done this now. It works. Destroyed the active_admin and reinstalled the latest version. Rails and Windows 7 dont like eachother much :D – zer02 May 16 '15 at 17:46
1

You also need to delete all the active admin related js and css files in your assets folder after running rails destroy active_admin:install

Moharnab Saikia
  • 487
  • 6
  • 10