0

I'm using devise and I can't add an user neither via no via seeds.rb. Here is a rails console:

irb(main):100:0> a = User.new
=> #<User id: nil, email: "", encrypted_password: "", reset_password_token: nil, reset_password_sent_at: nil,......etc>
irb(main):111:0> a.email = "[email protected]"
=> "[email protected]"

irb(main):116:0> a.password = "1234a"
=> "1234a"
irb(main):117:0> a.password
=> "1234a"
irb(main):119:0> a.password_confirmation = "1234a"
=> "1234a"
irb(main):120:0> a.password_confirmation == a.password
=> true
irb(main):121:0> a.save!
   (0.8ms)  BEGIN
  User Load (1.2ms)  SELECT "users".* FROM "users" WHERE "users"."reset_password_token" = 'M9Xg7pYuPkgysuirxoj8' LIMIT 1
  User Load (1.1ms)  SELECT "users".* FROM "users" WHERE "users"."reset_password_token" = '4y8Vdn9b7nsC2QqtkCSs' LIMIT 1
  User Exists (0.7ms)  SELECT 1 AS one FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
  User Exists (0.8ms)  SELECT 1 AS one FROM "users" WHERE LOWER("users"."login") = LOWER('login1') LIMIT 1
  User Exists (0.6ms)  SELECT 1 AS one FROM "users" WHERE "users"."email" = '[email protected]' LIMIT 1
   (0.4ms)  ROLLBACK
ActiveRecord::RecordInvalid: Validation failed: Password doesn't match confirmation
2
  • 1
    What does your User model look like
    – ahmet
    Jun 21, 2013 at 11:16
  • notice that you don't need to pass a password_confirmation in an explicit way - you may just set a a.password. But in any way that wouldn't harm, so may be you have some custom validators or hooks that may reassign a password_confirmation ? Jun 22, 2013 at 15:52

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.