安装Active Admin并获取ArgumentError

时间:2013-08-14 21:47:20

标签: ruby-on-rails devise routes activeadmin

我第一次尝试使用ActiveAdmin w / Rails 4.安装所有依赖宝石后,我尝试运行安装程序,即:

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 

唯一的问题是,如果我跳过Devise用户类,我不确定如何配置'config / initializers / active_admin.rb'?

有关为何会发生这种情况的任何想法?

2 个答案:

答案 0 :(得分:1)

使用ActiveAdmin升级到rails 4时出现了同样的错误,结果发现此行在我的routes中重复了两次.rb:ActiveAdmin.routes(self)我删除了第二个实例,错误就消失了。

答案 1 :(得分:1)

除了安德烈的回答 - 由于错误导致资产未正确安装。您必须运行rails g active_admin:assets才能在管道中安装js / css资产。