数据库已被锁定?

Mat*_*man 4 ruby-on-rails

如何修复数据库锁...因为我的测试没有通过 - 它在同一类别中进行了一系列测试失败.谢谢!

1) UsersController GET 'edit' should have a link to change the Gravatar
     Failure/Error: @user = Factory(:user)
     SQLite3::BusyException: database is locked: INSERT INTO "users" ("created_at", "email", "encrypted_password", "name", "salt", "updated_at") VALUES ('2011-05-29 03:47:07.510067', 'mberman84@gmail.com', 'fc70fcb4b094b388d87c5054ed9b0bfa06f53431d44c527e852c5bdffd3a0fa8', 'Matthew Berman', NULL, '2011-05-29 03:47:07.510067')
     # ./spec/controllers/users_controller_spec.rb:128:in `block (3 levels) in <top (required)>'
Run Code Online (Sandbox Code Playgroud)

Cha*_*rdy 17

这是因为Rails控制台会话正在打开.为了在将来解决这个问题,请确保bin/rails console -s在访问SQLite 3 DB时确保退出任何控制台会话.

  • 如果其他人对rails选项有点困惑/无知,他就意味着脚本/ rails控制台-s.-s用于"sandbox",表示退出时将回滚所有更改.我想这意味着控制台不需要对数据库进行写锁定; 虽然为什么它会在命令之间保持写锁定对我来说是神秘的. (6认同)