Reputation: 3995
I am using both Devise and ActiveAdmin, and I have them sharing a single users
table via an is_admin flag. My routes file looks like this:
Site::Application.routes.draw do
devise_for :users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
That gives me these routes
Prefix Verb URI Pattern Controller#Action
new_user_session GET /admin/login(.:format) active_admin/devise/sessions#new
user_session POST /admin/login(.:format) active_admin/devise/sessions#create
destroy_user_session DELETE|GET /admin/logout(.:format) active_admin/devise/sessions#destroy
user_password POST /admin/password(.:format) active_admin/devise/passwords#create
new_user_password GET /admin/password/new(.:format) active_admin/devise/passwords#new
edit_user_password GET /admin/password/edit(.:format) active_admin/devise/passwords#edit
PATCH /admin/password(.:format) active_admin/devise/passwords#update
PUT /admin/password(.:format) active_admin/devise/passwords#update
cancel_user_registration GET /admin/cancel(.:format) devise/registrations#cancel
user_registration POST /admin(.:format) devise/registrations#create
new_user_registration GET /admin/sign_up(.:format) devise/registrations#new
edit_user_registration GET /admin/edit(.:format) devise/registrations#edit
PATCH /admin(.:format) devise/registrations#update
PUT /admin(.:format) devise/registrations#update
DELETE /admin(.:format) devise/registrations#destroy
I want the admin dashboard to be available from /admin
, but I want the user administration section to be available from /users
. So new_user_session
would be at /users/login
instead of /admin/login
.
Anyone accomplish this?
Upvotes: 4
Views: 2869
Reputation: 3995
It turns out that you can do this by omitting ActiveAdmin from devise. Instead of this:
Site::Application.routes.draw do
devise_for :users, ActiveAdmin::Devise.config
ActiveAdmin.routes(self)
end
Do this:
Site::Application.routes.draw do
devise_for :users
ActiveAdmin.routes(self)
end
Upvotes: 7
Reputation: 3195
Active Admin itself can be configured to live at /
:
# config/initializers/active_admin.rb
ActiveAdmin.setup do |config|
config.default_namespace = false
# ...
end
At the same time, individual pages can be configured to be in custom namespaces:
# app/admin/dashboard.rb
ActiveAdmin.register_page 'Dashboard', namespace: :admin do
# ...
end
Upvotes: 0