Skip to content

Instantly share code, notes, and snippets.

@hukl
Created June 10, 2010 10:49
Show Gist options
  • Save hukl/432818 to your computer and use it in GitHub Desktop.
Save hukl/432818 to your computer and use it in GitHub Desktop.
ruby-1.8.7-p249 > posts = Post.all
Post Load (0.4ms) SELECT * FROM "posts"
Post::Translation Load (0.4ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 1)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 2)
Post::Translation Load (0.3ms) SELECT * FROM "post_translations" WHERE ("post_translations"."locale" IN ('en')) AND ("post_translations".post_id = 2)
+----+-------------------------+-------------------------+------+-------+
| id | created_at | updated_at | body | title |
+----+-------------------------+-------------------------+------+-------+
| 1 | 2010-06-10 10:43:57 UTC | 2010-06-10 10:43:57 UTC | yyy | xxx |
| 2 | 2010-06-10 10:46:16 UTC | 2010-06-10 10:46:16 UTC | foo | hello |
+----+-------------------------+-------------------------+------+-------+
2 rows in set
ruby-1.8.7-p249 > posts.first.title
=> "xxx"
ruby-1.8.7-p249 > posts = Post.all(:include => [:translations])
Post Load (0.4ms) SELECT * FROM "posts"
Post::Translation Load (0.5ms) SELECT "post_translations".* FROM "post_translations" WHERE ("post_translations".post_id IN (1,2))
+----+-------------------------+-------------------------+------+-------+
| id | created_at | updated_at | body | title |
+----+-------------------------+-------------------------+------+-------+
| 1 | 2010-06-10 10:43:57 UTC | 2010-06-10 10:43:57 UTC | yyy | xxx |
| 2 | 2010-06-10 10:46:16 UTC | 2010-06-10 10:46:16 UTC | foo | hello |
+----+-------------------------+-------------------------+------+-------+
2 rows in set
ruby-1.8.7-p249 > posts.first.title
=> "xxx"
ruby-1.8.7-p249 >
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment