0

我在 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表在哪里呢?提前感谢您的帮助!

4

1 回答 1

2

我会查看您以前的迁移,看看是否有一个创建了users表的迁移。如果是这样,可能会删除该迁移。无论如何,我会进入您的rails dbconsole并手动删除users表格,然后rake db:migrate再次运行。

于 2013-04-10T21:21:26.293 回答