我在Rails 3.2.12中为我的Web应用程序添加了设计。我成功运行了$ rails generate devise:install
和$ rails generate devise User
。
这是我运行$ rake routes
时所得到的:
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
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
PUT /users(.:format) devise/registrations#update
DELETE /users(.:format) devise/registrations#destroy
root / pages#home
about GET /about(.:format) pages#about
当我尝试运行rake db:migrate
时,我收到以下错误:
== DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
rake aborted!
An error has occurred, this and all later migrations canceled:
SQLite3::SQLException: table "users" already exists: CREATE TABLE "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, "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 NOT NULL, "updated_at" datetime NOT NULL) /Users/andyHuynh/.rvm/gems/ruby-1.9.3-p327/gems/sqlite3-1.3.7/lib/sqlite3/database.rb:91:in `initialize'
它告诉我我已经有了'用户'表。如果是这种情况,这个sql表在哪里?在此先感谢您的帮助!
答案 0 :(得分:2)
我会查看您之前的迁移,看看是否有创建users
表的迁移。如果是这样,也许删除该迁移。在任何情况下,我都会进入您的rails dbconsole
并手动删除users
表,然后再次运行rake db:migrate
。