Skip to content

Instantly share code, notes, and snippets.

@Bajena
Created January 27, 2019 21:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Bajena/e5de36f4d3115e77683499e57fc536fb to your computer and use it in GitHub Desktop.
Save Bajena/e5de36f4d3115e77683499e57fc536fb to your computer and use it in GitHub Desktop.
Rails joins
Post.joins(:users).where(users: { country_code: 'PL' }).map { |post| post.title }
# SELECT "posts".* FROM "posts" INNER JOIN "users" ON "posts"."user_id" = "users"."id" WHERE "users"."country_code" = $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment