我正在关注 railstutorial 并且我坚持第 7 章(图 7.8 附近)
我无法使用 ActiveRecord 类的 update_attributes 方法更新属性
我正在采取的确切步骤和它给我的错误:
1.9.3p392 :026 > user = User.first
User Load (0.3ms) SELECT "users".* FROM "users" LIMIT 1
=> #<User id: 1, name: "John Denisov", email: "denisov@gmail.com", created_at: "2013-06-17 19:49:49", updated_at: "2013-06-17 19:49:49", password_digest: "$2a$10$eU2XgCqdKP9iBf7.2J4rKuBYmyicO42uahlm3DWwT7Xe...">
1.9.3p392 :027 > user.update_attributes(name: "Example User", email: "example@railstutorial.org", password: "foobar", password_confirmation: "foobar")
(0.1ms) begin transaction
User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE (LOWER("users"."email") = LOWER('example@railstutorial.org') AND "users"."id" != 1) LIMIT 1
(0.1ms) rollback transaction
=> false
为什么它会给我用户存在错误?这很明显,我正在尝试更新,而不是创建数据库条目。