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?
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.
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'
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With