Advertisement
Guest User

Untitled

a guest
Sep 29th, 2016
226
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Ruby 3.95 KB | None | 0 0
  1. Loading development environment (Rails 5.0.0.1)
  2. [1] pry(main)> admin = User.find_or_initialize_by(id: 1)
  3.   User Load (0.6ms)  SELECT  "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2  [["id", 1], ["LIMIT", 1]]
  4. => #<User:0x0000000510ab30
  5.  id: 1,
  6.  email: nil,
  7.  crypted_password: nil,
  8.  salt: nil,
  9.  first_name: nil,
  10.  last_name: nil,
  11.  created_at: nil,
  12.  updated_at: nil,
  13.  remember_me_token: nil,
  14.  remember_me_token_expires_at: nil,
  15.  reset_password_token: nil,
  16.  reset_password_token_expires_at: nil,
  17.  reset_password_email_sent_at: nil,
  18.  activation_state: nil,
  19.  activation_token: nil,
  20.  activation_token_expires_at: nil,
  21.  last_login_at: nil,
  22.  last_logout_at: nil,
  23.  last_activity_at: nil,
  24.  last_login_from_ip_address: nil>
  25. [2] pry(main)> admin.assign_attributes email: "admin@mail.com", first_name: "super", last_name: "admin", password: "qwerty"
  26. => nil
  27. [3] pry(main)> admin.valid?
  28.   User Exists (0.9ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "admin@mail.com"], ["LIMIT", 1]]
  29. => true
  30. [4] pry(main)> admin.save
  31.    (0.2ms)  BEGIN
  32.   User Exists (0.4ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "admin@mail.com"], ["LIMIT", 1]]
  33.   SQL (0.6ms)  INSERT INTO "users" ("id", "email", "crypted_password", "salt", "first_name", "last_name", "created_at", "updated_at", "activation_state", "activation_token") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id"  [["id", 1], ["email", "admin@mail.com"], ["crypted_password", "$2a$10$0icgSQkVz0AjseNFVTuE6ODu.p35u4GPHHJU/h131ViAKf/0UXOCG"], ["salt", "pALDV8aAC2vZib4ctjyM"], ["first_name", "super"], ["last_name", "admin"], ["created_at", 2016-09-29 10:46:12 UTC], ["updated_at", 2016-09-29 10:46:12 UTC], ["activation_state", "pending"], ["activation_token", "ax3zuYCubjK3eWPgmzCu"]]
  34.    (0.6ms)  COMMIT
  35. => true
  36. [5] pry(main)> user = User.new
  37. => #<User:0x00000006aa8998
  38.  id: nil,
  39.  email: nil,
  40.  crypted_password: nil,
  41.  salt: nil,
  42.  first_name: nil,
  43.  last_name: nil,
  44.  created_at: nil,
  45.  updated_at: nil,
  46.  remember_me_token: nil,
  47.  remember_me_token_expires_at: nil,
  48.  reset_password_token: nil,
  49.  reset_password_token_expires_at: nil,
  50.  reset_password_email_sent_at: nil,
  51.  activation_state: nil,
  52.  activation_token: nil,
  53.  activation_token_expires_at: nil,
  54.  last_login_at: nil,
  55.  last_logout_at: nil,
  56.  last_activity_at: nil,
  57.  last_login_from_ip_address: nil>
  58. [6] pry(main)> user.assign_attributes email: "test@mail.com", first_name: "test", last_name: "user", password: "qwerty"
  59. => nil
  60. [7] pry(main)> user.valid?
  61.   User Exists (0.5ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "test@mail.com"], ["LIMIT", 1]]
  62. => true
  63. [8] pry(main)> user.save
  64.    (0.2ms)  BEGIN
  65.   User Exists (0.4ms)  SELECT  1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2  [["email", "test@mail.com"], ["LIMIT", 1]]
  66.   SQL (1.5ms)  INSERT INTO "users" ("email", "crypted_password", "salt", "first_name", "last_name", "created_at", "updated_at", "activation_state", "activation_token") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id"  [["email", "test@mail.com"], ["crypted_password", "$2a$10$wz2vvNZRiF04Bo6LF9GmtOTwss5sbHPG4zJ2Jc15xj7XYux7IJYzG"], ["salt", "ZxkZNjLp2rwJ7izoGRFP"], ["first_name", "test"], ["last_name", "user"], ["created_at", 2016-09-29 10:47:09 UTC], ["updated_at", 2016-09-29 10:47:09 UTC], ["activation_state", "pending"], ["activation_token", "ag3pv111TAYmmawMHamZ"]]
  67.    (0.1ms)  ROLLBACK
  68. ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR:  duplicate key value violates unique constraint "users_pkey"
  69. DETAIL:  Key (id)=(1) already exists.
  70. : INSERT INTO "users" ("email", "crypted_password", "salt", "first_name", "last_name", "created_at", "updated_at", "activation_state", "activation_token") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9) RETURNING "id"
  71. from /home/artem/.rvm/gems/ruby-2.3.0@qtile/gems/activerecord-5.0.0.1/lib/active_record/connection_adapters/postgresql_adapter.rb:598:in `async_exec'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement