我第一次尝试使用带有 Rails 4 的 ActiveAdmin。安装所有依赖的 gem 后,我尝试运行安装程序,即:
rails generate active_admin:install
这样做会给我以下错误:
in `add_route': Invalid route name, already in use: 'admin_root' (ArgumentError)
但是,我在 routes.rb 中没有任何“admin_root”路由,所以我有点困惑。这是运行“rake routes”的输出:
Prefix Verb URI Pattern Controller#Action
exams GET /exams(.:format) exams#index
POST /exams(.:format) exams#create
new_exam GET /exams/new(.:format) exams#new
edit_exam GET /exams/:id/edit(.:format) exams#edit
exam GET /exams/:id(.:format) exams#show
PATCH /exams/:id(.:format) exams#update
PUT /exams/:id(.:format) exams#update
DELETE /exams/:id(.:format) exams#destroy
new_user_session GET /users/sign_in(.:format) devise/sessions#new
user_session POST /users/sign_in(.:format) devise/sessions#create
destroy_user_session GET /users/sign_out(.:format) devise/sessions#destroy
user_password POST /users/password(.:format) devise/passwords#create
new_user_password GET /users/password/new(.:format) devise/passwords#new
edit_user_password GET /users/password/edit(.:format) devise/passwords#edit
PATCH /users/password(.:format) devise/passwords#update
PUT /users/password(.:format) devise/passwords#update
cancel_user_registration GET /users/cancel(.:format) devise/registrations#cancel
user_registration POST /users(.:format) devise/registrations#create
new_user_registration GET /users/sign_up(.:format) devise/registrations#new
edit_user_registration GET /users/edit(.:format) devise/registrations#edit
PATCH /users(.:format) devise/registrations#update
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
root GET / composer#index
home GET /home(.:format) home#index
GET /exam_db/:exam_name/:chapter_name/:topic_name/:item_name(.:format) exam_db#gateway
exam_db_gateway GET /exam_db/gateway(.:format) exam_db#gateway
这是完整的错误:
gems/actionpack-4.0.0/lib/action_dispatch/routing/route_set.rb:409:in `add_route': Invalid route name, already in use: 'admin_root' (ArgumentError)
You may have defined two routes with the same name using the `:as` option, or you may be overriding a route already defined by a resource with the same naming. For the latter, you can restrict the routes created with `resources` as explained here:
另外值得注意的是,如果我决定完全跳过 Devise 用户类,它可以工作:
rails generate active_admin:install --skip-users
唯一的问题是,如果我跳过设计用户类,我不确定如何配置“config/initializers/active_admin.rb”?
关于为什么会发生这种情况的任何想法?