aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/relation
diff options
context:
space:
mode:
authorRyuta Kamizono <kamipo@gmail.com>2019-04-01 09:48:28 +0900
committerRyuta Kamizono <kamipo@gmail.com>2019-04-01 09:49:18 +0900
commit15501148a29b9a36363a213531156883e5095a2e (patch)
treee502a9b5a48d15120a849ee44a5d9d53a4aaf53d /activerecord/lib/active_record/relation
parent7c5814c6e0de3d0694debd1d41ebeca038cdd11d (diff)
parent0f8db2126da680bf10de1652ea8fb5171b74f940 (diff)
downloadrails-15501148a29b9a36363a213531156883e5095a2e.tar.gz
rails-15501148a29b9a36363a213531156883e5095a2e.tar.bz2
rails-15501148a29b9a36363a213531156883e5095a2e.zip
Merge pull request #35727 from zinosama/zzz/update-doc-for-includes
Update API doc for #includes on unnecessary #references [ci skip]
Diffstat (limited to 'activerecord/lib/active_record/relation')
-rw-r--r--activerecord/lib/active_record/relation/query_methods.rb8
1 files changed, 7 insertions, 1 deletions
diff --git a/activerecord/lib/active_record/relation/query_methods.rb b/activerecord/lib/active_record/relation/query_methods.rb
index c37855172b..b0535cfff5 100644
--- a/activerecord/lib/active_record/relation/query_methods.rb
+++ b/activerecord/lib/active_record/relation/query_methods.rb
@@ -100,7 +100,7 @@ module ActiveRecord
#
# === conditions
#
- # If you want to add conditions to your included models you'll have
+ # If you want to add string conditions to your included models, you'll have
# to explicitly reference them. For example:
#
# User.includes(:posts).where('posts.name = ?', 'example')
@@ -111,6 +111,12 @@ module ActiveRecord
#
# Note that #includes works with association names while #references needs
# the actual table name.
+ #
+ # If you pass the conditions via hash, you don't need to call #references
+ # explicitly, as #where references the tables for you. For example, this
+ # will work correctly:
+ #
+ # User.includes(:posts).where(posts: { name: 'example' })
def includes(*args)
check_if_method_has_arguments!(:includes, args)
spawn.includes!(*args)