Question

I ran this in a rails console:

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 
Was it helpful?

Solution

There must be some validation which is stopping this user to be saved. Just check your validations in User model. You can also check the errors on this user using u.errors.full_messages.to_sentence

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top