aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib
diff options
context:
space:
mode:
authorzino <rhu5@u.rochester.edu>2019-03-23 13:46:10 -0700
committerzino <rhu5@u.rochester.edu>2019-03-23 13:46:10 -0700
commit0f8db2126da680bf10de1652ea8fb5171b74f940 (patch)
treee844d113e76f9f1f1738d48b5789205da307148f /activerecord/lib
parentff7948b1c2cbdf5527e40e60a4f2ef7621445d55 (diff)
downloadrails-0f8db2126da680bf10de1652ea8fb5171b74f940.tar.gz
rails-0f8db2126da680bf10de1652ea8fb5171b74f940.tar.bz2
rails-0f8db2126da680bf10de1652ea8fb5171b74f940.zip
[ci skip] Update doc for unnecessary #references
Update doc for #includes to clarify that #references is unnecessary when conditions are passed into #includes as a hash.
Diffstat (limited to 'activerecord/lib')
-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 6f0f2125dc..7717852753 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)