Ruby on Rails Saturday, December 26, 2015

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: "krfg@example.com", 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?

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-talk+unsubscribe@googlegroups.com.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/f4aa7a44-df5b-4365-9f91-8592d0679f33%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment