Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Remove dashboard page from ActiveAdmin

I'd like to replace the default dashboard page in ActiveAdmin with a custom page.

This is mainly because I want a page based on a resource, i.e. a page generated with ActiveAdmin.register and not with ActiveAdmin.register_page.

I just deleted the dashboard.rb file, hoping that MyCustomAdmin that is a regular (and working) ActiveAdmin resource, would simply take the place of dashboard.

But it didn't, instead I'm getting this error:

uninitialized constant Admin::DashboardController

So I changed the ActiveAdmin initializer and set:

# config/initializers/active_admin.rb

config.root_to = 'my_custom_admin#index'

I also have MyCustomAdmin like this:

# app/admin/my_custom_admin.rb

ActiveAdmin.register MyCustomAdmin do
  menu :priority => 1, :label => 'Report'

  index do
    column "column 1 title", :column1
  end

end

Among my models I also have:

# app/models/my_custom_admin.rb

class MyCustomAdmin < ActiveRecord::Base
end

So the problem is when I try to access on localhost:3000/admin I get the error:

uninitialized constant Admin::MyCustomAdminController

But if I go to localhost:3000/admin/my_custom_admin it works just fine.

Why is localhost:3000/admin not working?

like image 918
AgostinoX Avatar asked Jul 11 '13 15:07

AgostinoX


3 Answers

Active admin generates a controller for you. And the controller is pluralized.

So, in the active admin initializer you should use plural form:

config.root_to = 'my_custom_admins#index'

And this is the solution.

It complains that

uninitialized constant Admin::MyCustomAdminController

because what it has initialized is:

MyCustomAdminsController

instead.

like image 195
AgostinoX Avatar answered Nov 14 '22 15:11

AgostinoX


In app/admin/dashboard.rb

set menu false to hide the dashboard button.

In config/initializers/active_admin.rb

set something like this:

config.root_to = 'entities#index'

like image 28
sumitsv21 Avatar answered Nov 14 '22 15:11

sumitsv21


Using ActiveAdmin 0.5.0 I was able to:

1) make a page other than the dashboard the default ActiveAdmin page.

2) remove the dashboard tab from the menu. (still accessible via url)

Additions to config/initializers/active_admin.rb :

ActiveAdmin.setup do |config|
...
  # The default start page becomes SomethingElse
  config.root_to = 'something_else#index'
end

module ActiveAdmin
  module Dashboards
    class << self
      # Remove the dashboard tab from the menu
      alias_method :original_add_to_menu, :add_to_menu
      def add_to_menu(namespace, menu)
        # empty
      end
    end
  end
end
like image 24
Edwin Meyer Avatar answered Nov 14 '22 16:11

Edwin Meyer