Skip to content

Instantly share code, notes, and snippets.

@alexhanh
Created December 9, 2011 16:29
Show Gist options
  • Select an option

  • Save alexhanh/1452233 to your computer and use it in GitHub Desktop.

Select an option

Save alexhanh/1452233 to your computer and use it in GitHub Desktop.
irb(main):021:0> Stream.first.tags
Stream Load (2.3ms) SELECT "streams".* FROM "streams" LIMIT 1
Tag Load (1.6ms) SELECT "tags".* FROM "tags" INNER JOIN "taggings" ON "tags"."id" = "taggings"."tag_id" WHERE "taggings"."stream_id" = 818
=> [#<Tag id: 1, name: "korean">]
irb(main):022:0> Stream.includes(:tags).first.tags
Stream Load (1.9ms) SELECT "streams".* FROM "streams" LIMIT 1
Tagging Load (0.5ms) SELECT "taggings".* FROM "taggings" WHERE "taggings"."stream_id" IN (818)
Tag Load (0.4ms) SELECT "tags".* FROM "tags" WHERE "tags"."id" IN (1)
=> [#<Tag id: 1, name: "korean">]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment