我在 Rails 控制台中运行了这个:
u = User.first
User Load (0.3ms) SELECT "users".* FROM "users" ORDER BY "users"."id" ASC LIMIT 1
=> #<User id: 4, name: "Administrator", email: "administrator@wdis.com", created_at: "2013-09-27 01:01:54", updated_at: "2013-09-29 23:52:11", password_digest: ".......", remember_token: "........", admin: true, num_credits: nil>
2.0.0p247 :002 > u.num_credits = 1
=> 1
2.0.0p247 :003 > u.num_credits
=> 1
2.0.0p247 :004 > u.save
(0.3ms) begin transaction
User Exists (0.3ms) SELECT 1 AS one FROM "users" WHERE (LOWER("users"."email") = LOWER('administrator@wdis.com') AND "users"."id" != 4) LIMIT 1
(0.2ms) rollback transaction
=> false