Skip to content

Instantly share code, notes, and snippets.

@Shinpeim
Created March 27, 2015 09:24
Show Gist options
  • Save Shinpeim/7f903fee0a574e6f7851 to your computer and use it in GitHub Desktop.
Save Shinpeim/7f903fee0a574e6f7851 to your computer and use it in GitHub Desktop.
irb(main):005:0> article = Article.select(["articles.id as id", "categories.name as category_name"]).joins(:category)[0]
Article Load (0.3ms) SELECT articles.id as id, categories.name as category_name FROM "articles" INNER JOIN "categories" ON "categories"."id" = "articles"."category_id"
=> #<Article id: 6>
irb(main):006:0> article.id
=> 6
irb(main):007:0> article.category_name
=> "live_info"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment