Have any of you any idea why at Heroku the first user created would get
id
2 instead of 1, and ActiveRecord cannot find user with id 1?
After deploying my application I created a new user and noticed that the
address bar was reporting number 2 at the end of the url:
http://…herokuapp.com/users/2.
So I checked with rails console in production environment first and then
at
Heroku. There seemed to be nothing irregular in my production
environment
(running sqlite3),
With heroku run console I got the following results:
irb(main):001:0> User.count
(4.9ms) SELECT COUNT() FROM “users”
(4.9ms) SELECT COUNT() FROM “users”=> 1
irb(main):002:0> User.first
User Load (2.5ms) SELECT “users”.* FROM “users” ORDER BY
“users”.“id” ASC LIMIT 1
User Load (2.5ms) SELECT “users”.* FROM “users” ORDER BY
“users”.“id” ASC LIMIT 1=> #<User id: 2, name: “krfg”, email:
“[email protected]”, created_at: “2015-12-20 13:56:04”, updated_at:
“2015-12-20 13:56:04”, password_digest: “…”>
irb(main):001:0> User.find(1)
User Load (1.1ms) SELECT “users”.* FROM “users” WHERE “users”.“id” =
$1 LIMIT 1 [[“id”, 1]]
User Load (1.1ms) SELECT “users”.* FROM “users” WHERE “users”.“id” =
$1 LIMIT 1 [[“id”, 1]]ActiveRecord::RecordNotFound: Couldn’t find User
with ‘id’=1
I am not an experienced user, I am just a beginner, but to me it is
strange
that User Load is repeated twice.
What do you think is wrong?