|
|
|
|
|
by psadauskas
51 days ago
|
|
Fun story about that: In Ruby 2.x, the version GitHub originally launched with, every object implemented the method `id`, which returned the object id (in 3.x, it was renamed to `object_id`). Every object had this id, ActiveRecord models, strings, floats, integers, booleans, etc. Some objects had fixed object ids, like `true.object_id #=> 20`, `false.object_id #=> 0`, `123.object_id #=> 247 (2n+1)`. The `object_id` for `nil` is `4`. Yehuda Katz was the first external user of GitHub after the cofounders, so his github user id is `4`. The way Rails works, if you want to look up a user record, you do it by id: author = comment.author
user = User.find(author.id)
Now, if there was some bug, and for some reason a comment had no author, `comment.author` would return `nil`, `nil.id` would return `4`, and the UI would show Yehuda as the author in the UI. People would ask, "Who is this Yehuda guy, and why is he commenting on my PRs?" |
|