Skip to content

Instantly share code, notes, and snippets.

@benbonnet
Created April 17, 2014 11:40
Show Gist options
  • Save benbonnet/10976474 to your computer and use it in GitHub Desktop.
Save benbonnet/10976474 to your computer and use it in GitHub Desktop.
2.0.0-p353 :060 > u = User.where("user_type = 2").first; puts u.id; nil
User Load (0.8ms) SELECT `users`.* FROM `users` WHERE (user_type = 2) ORDER BY users.created_at DESC LIMIT 1
673
=> nil
2.0.0-p353 :061 > test_artist = u.artists.first; puts test_artist.id; nil
Artist Load (0.6ms) SELECT `artists`.* FROM `artists` WHERE `artists`.`user_id` = 673 ORDER BY artists.created_at DESC LIMIT 1
162
=> nil
2.0.0-p353 :062 > test_user = test_artist.user; puts test_user.id; nil
User Load (0.5ms) SELECT `users`.* FROM `users` WHERE `users`.`id` = 673 ORDER BY users.created_at DESC LIMIT 1
673
=> nil
2.0.0-p353 :063
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment