我跑了:
rails g active_admin:install
并收到此错误:
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:
我甚至无法运行rake路线。我这样做时会遇到同样的错误。
这是我的路线档案:
Stynyl::Application.routes.draw do
resources :things
devise_for :users
resources :users, only: [:show, :new, :create]
get '/about', to: 'pages#about'
root 'things#index'
end
EDITS
我做了一个:
rails destroy active_admin:install
再次运行install命令。得到同样的错误。路线名称无效,已在使用中。
从架构中清除ActiveAdmin。仍然有错误。
还注意到卸载不是100%干净。留下一些样式和javascript文件,但那些似乎根本没有影响应用程序。
我更新了我的Gemfile:
gem 'activeadmin', github: 'gregbell/active_admin'
gem 'ransack', github: 'ernie/ransack'
gem 'inherited_resources', github: 'josevalim/inherited_resources'
gem 'formtastic', github: 'justinfrench/formtastic'
group :development do
gem 'sqlite3'
end
试图运行ActiveAdmin安装生成器并得到相同的错误。我无法迁移数据库。这是我得到的错误:
SQLite3::SQLException: table "admin_users" already exists: CREATE TABLE "admin_users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "email" varchar(255) DEFAULT '' NOT NULL, "encrypted_password" varchar(255) DEFAULT '' NOT NULL, "reset_password_token" varchar(255), "reset_password_sent_at" datetime, "remember_created_at" datetime, "sign_in_count" integer DEFAULT 0 NOT NULL, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar(255), "last_sign_in_ip" varchar(255), "created_at" datetime, "updated_at" datetime) /Users/DylanRichards/.rvm/gems/ruby-2.0.0-p247/gems/sqlite3-1.3.8/lib/sqlite3/database.rb:91:in `initialize'
检查了我的架构文件,我甚至没有看到“admin_users”表。
然而,我现在可以做的是rake routes
。这是输出:
Prefix Verb URI Pattern Controller#Action
new_admin_user_session GET /admin/login(.:format) active_admin/devise/sessions#new
admin_user_session POST /admin/login(.:format) active_admin/devise/sessions#create
destroy_admin_user_session DELETE|GET /admin/logout(.:format) active_admin/devise/sessions#destroy
admin_user_password POST /admin/password(.:format) active_admin/devise/passwords#create
new_admin_user_password GET /admin/password/new(.:format) active_admin/devise/passwords#new
edit_admin_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
things GET /things(.:format) things#index
POST /things(.:format) things#create
new_thing GET /things/new(.:format) things#new
edit_thing GET /things/:id/edit(.:format) things#edit
thing GET /things/:id(.:format) things#show
PATCH /things/:id(.:format) things#update
PUT /things/:id(.:format) things#update
DELETE /things/:id(.:format) things#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 DELETE /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
admin_root GET /admin(.:format) admin/dashboard#index
batch_action_admin_admin_users POST /admin/admin_users/batch_action(.:format) admin/admin_users#batch_action
admin_admin_users GET /admin/admin_users(.:format) admin/admin_users#index
POST /admin/admin_users(.:format) admin/admin_users#create
new_admin_admin_user GET /admin/admin_users/new(.:format) admin/admin_users#new
edit_admin_admin_user GET /admin/admin_users/:id/edit(.:format) admin/admin_users#edit
admin_admin_user GET /admin/admin_users/:id(.:format) admin/admin_users#show
PATCH /admin/admin_users/:id(.:format) admin/admin_users#update
PUT /admin/admin_users/:id(.:format) admin/admin_users#update
DELETE /admin/admin_users/:id(.:format) admin/admin_users#destroy
admin_dashboard GET /admin/dashboard(.:format) admin/dashboard#index
batch_action_admin_comments POST /admin/comments/batch_action(.:format) admin/comments#batch_action
admin_comments GET /admin/comments(.:format) admin/comments#index
POST /admin/comments(.:format) admin/comments#create
admin_comment GET /admin/comments/:id(.:format) admin/comments#show
users POST /users(.:format) users#create
new_user GET /users/new(.:format) users#new
user GET /users/:id(.:format) users#show
about GET /about(.:format) pages#about
root GET / things#index
答案 0 :(得分:4)
所以I found someone having the same problem in this issue - 但是说问题是ActiveAdmin将ActiveAdmin.routes(self)
文件放入config/routes.rb
文件中两次。
但是,你的路线根本没有那条线 - 我猜是因为你跑了rails destroy active_admin:install
,但这并不能解释为什么你在摧毁后仍然会得到那个错误。< / p>
你正在使用git吗?你能看到生成中是否有任何其他修改可能没有被破坏清除? ActiveAdmin问题还暗示如果在生成期间发生错误,则生成无法正确完成。
要尝试的另一件事是再次运行生成器,然后检查您的路线并确保ActiveAdmin.routes(self)
仅出现一次。
答案 1 :(得分:0)
通过卸载ActiveAdmin,重新安装它,删除路由文件中的第二个ActiveAdmin.routes(self),然后删除我的模式文件来解决它。之后,我运行了rake db:reset
并重新启动了数据库。