3 ms·
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,
by psadauskas 5mo 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?"
- Dragonai 5mo agoThis is too funny. Thanks for sharing this tidbit!
- tksb 5mo agoThese are the fun anecdotes that make perusing comments here so worth it. Thanks for sharing!
- sikozu 5mo agoI love this story, makes me wonder how many other fun bugs on GitHub have been lost to time.
- byroot 5mo agoSimilarly, when writing Facebook apps with Rails, when you'd hit that same bug you'd see Mark Zuckerbeg: https://www.facebook.com/profile.php?id=4 https://www.facebook.com/profile.php?id=4