diff options
author | Jared Beck <jared@jaredbeck.com> | 2015-11-25 15:07:34 -0500 |
---|---|---|
committer | Jared Beck <jared@jaredbeck.com> | 2015-11-25 15:17:29 -0500 |
commit | aad6000f0b82d5113b82e40f1757d37c75d5de1c (patch) | |
tree | 5a545f2ab26a54f5b9c6bd65f785275b41db17dc | |
parent | 3fcc0ca99107fa57110421b392f5854555f17fe2 (diff) | |
download | rails-aad6000f0b82d5113b82e40f1757d37c75d5de1c.tar.gz rails-aad6000f0b82d5113b82e40f1757d37c75d5de1c.tar.bz2 rails-aad6000f0b82d5113b82e40f1757d37c75d5de1c.zip |
Docs: ActiveRecord::QueryMethods#joins
[ci skip]
-rw-r--r-- | activerecord/lib/active_record/relation/query_methods.rb | 24 |
1 files changed, 22 insertions, 2 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb index 7a4bf5338d..dbecb842b5 100644 --- a/activerecord/lib/active_record/relation/query_methods.rb +++ b/activerecord/lib/active_record/relation/query_methods.rb @@ -411,10 +411,30 @@ module ActiveRecord self end - # Performs a joins on +args+: + # Performs a joins on +args+. The given symbol(s) should match the name of + # the association(s). # # User.joins(:posts) - # # SELECT "users".* FROM "users" INNER JOIN "posts" ON "posts"."user_id" = "users"."id" + # # SELECT "users".* + # # FROM "users" + # # INNER JOIN "posts" ON "posts"."user_id" = "users"."id" + # + # Multiple joins: + # + # User.joins(:posts, :account) + # # SELECT "users".* + # # FROM "users" + # # INNER JOIN "posts" ON "posts"."user_id" = "users"."id" + # # INNER JOIN "accounts" ON "accounts"."id" = "users"."account_id" + # + # Nested joins: + # + # User.joins(posts: [:comments]) + # # SELECT "users".* + # # FROM "users" + # # INNER JOIN "posts" ON "posts"."user_id" = "users"."id" + # # INNER JOIN "comments" "comments_posts" + # # ON "comments_posts"."post_id" = "posts"."id" # # You can use strings in order to customize your joins: # |