Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Loading development environment (Rails 5.0.0.1)
- [1] pry(main)> admin = User.find_or_initialize_by(id: 1)
- User Load (0.6ms) SELECT "users".* FROM "users" WHERE "users"."id" = $1 LIMIT $2 [["id", 1], ["LIMIT", 1]]
- => #<User:0x0000000510ab30
- id: 1,
- email: nil,
- crypted_password: nil,
- salt: nil,
- first_name: nil,
- last_name: nil,
- created_at: nil,
- updated_at: nil,
- remember_me_token: nil,
- remember_me_token_expires_at: nil,
- reset_password_token: nil,
- reset_password_token_expires_at: nil,
- reset_password_email_sent_at: nil,
- activation_state: nil,
- activation_token: nil,
- activation_token_expires_at: nil,
- last_login_at: nil,
- last_logout_at: nil,
- last_activity_at: nil,
- last_login_from_ip_address: nil>
- [2] pry(main)> admin.assign_attributes email: "admin@mail.com", first_name: "super", last_name: "admin", password: "qwerty"
- => nil
- [3] pry(main)> admin.valid?
- User Exists (0.9ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "admin@mail.com"], ["LIMIT", 1]]
- => true
- [4] pry(main)> admin.save
- (0.2ms) BEGIN
- User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "admin@mail.com"], ["LIMIT", 1]]
- 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"]]
- (0.6ms) COMMIT
- => true
- [5] pry(main)> user = User.new
- => #<User:0x00000006aa8998
- id: nil,
- email: nil,
- crypted_password: nil,
- salt: nil,
- first_name: nil,
- last_name: nil,
- created_at: nil,
- updated_at: nil,
- remember_me_token: nil,
- remember_me_token_expires_at: nil,
- reset_password_token: nil,
- reset_password_token_expires_at: nil,
- reset_password_email_sent_at: nil,
- activation_state: nil,
- activation_token: nil,
- activation_token_expires_at: nil,
- last_login_at: nil,
- last_logout_at: nil,
- last_activity_at: nil,
- last_login_from_ip_address: nil>
- [6] pry(main)> user.assign_attributes email: "test@mail.com", first_name: "test", last_name: "user", password: "qwerty"
- => nil
- [7] pry(main)> user.valid?
- User Exists (0.5ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "test@mail.com"], ["LIMIT", 1]]
- => true
- [8] pry(main)> user.save
- (0.2ms) BEGIN
- User Exists (0.4ms) SELECT 1 AS one FROM "users" WHERE "users"."email" = $1 LIMIT $2 [["email", "test@mail.com"], ["LIMIT", 1]]
- 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"]]
- (0.1ms) ROLLBACK
- ActiveRecord::RecordNotUnique: PG::UniqueViolation: ERROR: duplicate key value violates unique constraint "users_pkey"
- DETAIL: Key (id)=(1) already exists.
- : 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"
- 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