简体   繁体   中英

How can I change the default URL of ActiveAdmin?

By default, ActiveAdmin is running under /admin. Is there any way change that?

Yes. You need to add the following line to the config/initializers/active_admin.rb file:

config.default_namespace = :your_desired_namespace

This will create a http://yourdomain.name/your_desired_namespace

Do note, that you will need to update your routes accordingly (ie admin_user_path will become your_desired_namespace_user_path ).

Alternatively to @Amir answer. If you don't care about the exact path, and just want to change the route to something less obvious without needing to change your routes. On the routes file you can just call ActiveAdmin like:

Rails.application.routes.draw do
  scope 'something-else' do
    ActiveAdmin.routes(self)
    get '/', to: 'admin/dashboard#index'
  end
end

Then your routes would be /something-else/admin and you could access the dashboard on /something-else .

And you could still use the regular helpers like admin_user_path .

仅作进一步参考,如果您想从根路径作为独立应用程序运行ActiveAdmin,请使用以下命令:

config.default_namespace = false

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM