By default, ActiveAdmin is running under /admin. Is there any way change that?
默认情况下,ActiveAdmin在/ admin下运行。有什么办法改变吗?
3 个解决方案
#1
27
Yes. You need to add the following line to the config/initializers/active_admin.rb
file:
是。您需要将以下行添加到config / initializers / active_admin.rb文件中:
config.default_namespace = :your_desired_namespace
This will create a http://yourdomain.name/your_desired_namespace
这将创建一个http://yourdomain.name/your_desired_namespace
Do note, that you will need to update your routes accordingly (i.e admin_user_path
will become your_desired_namespace_user_path
).
请注意,您需要相应地更新路由(即admin_user_path将成为your_desired_namespace_user_path)。
#2
12
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:
或@Amir回答。如果您不关心确切的路径,只想将路线更改为不太明显的路线,而无需更改路线。在路线文件中,您可以像以下一样调用ActiveAdmin:
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
.
然后您的路线将是/ something-else / admin,您可以访问/ something-else上的仪表板。
And you could still use the regular helpers like admin_user_path
.
你仍然可以使用像admin_user_path这样的常规助手。
#3
4
Just for further reference, if you want to run ActiveAdmin from the root path as a standalone app, use this:
仅供进一步参考,如果您想从根路径运行ActiveAdmin作为独立应用程序,请使用以下命令:
config.default_namespace = false
#1
27
Yes. You need to add the following line to the config/initializers/active_admin.rb
file:
是。您需要将以下行添加到config / initializers / active_admin.rb文件中:
config.default_namespace = :your_desired_namespace
This will create a http://yourdomain.name/your_desired_namespace
这将创建一个http://yourdomain.name/your_desired_namespace
Do note, that you will need to update your routes accordingly (i.e admin_user_path
will become your_desired_namespace_user_path
).
请注意,您需要相应地更新路由(即admin_user_path将成为your_desired_namespace_user_path)。
#2
12
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:
或@Amir回答。如果您不关心确切的路径,只想将路线更改为不太明显的路线,而无需更改路线。在路线文件中,您可以像以下一样调用ActiveAdmin:
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
.
然后您的路线将是/ something-else / admin,您可以访问/ something-else上的仪表板。
And you could still use the regular helpers like admin_user_path
.
你仍然可以使用像admin_user_path这样的常规助手。
#3
4
Just for further reference, if you want to run ActiveAdmin from the root path as a standalone app, use this:
仅供进一步参考,如果您想从根路径运行ActiveAdmin作为独立应用程序,请使用以下命令:
config.default_namespace = false