简体   繁体   English

SQLite3 :: SQLException:Rails应用没有这样的表

[英]SQLite3::SQLException: no such table for Rails app

I'm having some problems with signing up in my rails app, with the error coming up of 我在Rails应用程序中注册时遇到一些问题,出现错误
"column email is not unique" “列电子邮件不是唯一的”
despite the fact I know that I haven't used this particular email address before. 尽管我知道我以前从未使用过这个特定的电子邮件地址。 I thought I'd check my database anyway, and ran: 我以为我还是要检查数据库,然后运行:

rails console -e=test

looking at Users.all to see what records were saved. 查看Users.all以查看保存了哪些记录。 However, not only are none of them saved, but I get the error: 但是,不仅没有一个被保存,而且我得到了错误:

**SQLite3::SQLException: no such table: users: SELECT "users".* FROM "users"
ActiveRecord::StatementInvalid: SQLite3::SQLException: no such table: users: SELECT "users".* FROM "users"**  

But in my schema, it clearly says 但是在我的模式中,它清楚地说

  create_table "users", force: true do |t|
    t.string   "email",                  default: "", null: false
    t.string   "encrypted_password",     default: "", null: false
    t.string   "reset_password_token"
    t.datetime "reset_password_sent_at"
    t.datetime "remember_created_at"
    t.integer  "sign_in_count",          default: 0,  null: false
    t.datetime "current_sign_in_at"
    t.datetime "last_sign_in_at"
    t.string   "current_sign_in_ip"
    t.string   "last_sign_in_ip"
    t.datetime "created_at"
    t.datetime "updated_at"
    t.string   "provider"
    t.string   "uid"
  end

and nothing happens if I keep trying to db:migrate or db:migrate RAILS_ENV=development . 如果我继续尝试db:migratedb:migrate RAILS_ENV=development ,则不会发生任何事情。
Any suggestions please? 有什么建议吗?

Edit: running rails console (not -e=test) results in this: 编辑:运行rails console (不是-e = test)导致以下结果:

#<ActiveRecord::Relation [#<User id: 1, email: "", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil, remember_created_at: nil, sign_in_count: 0, current_sign_in_at: nil, last_sign_in_at: nil, current_sign_in_ip: nil, last_sign_in_ip: nil, created_at: "2014-09-22 14:03:39", updated_at: "2014-09-22 14:03:39", provider: nil, uid: nil>]> 

it looks like you haven't created your database in your test environment. 看来您尚未在测试环境中创建数据库。 Run: 跑:

rake db:create RAILS_ENV=test 
rake db:migrate RAILS_ENV=test 

that should hopefully solve it 那应该解决它

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM