File: //usr/local/rvm/gems/ruby-2.6.8/doc/activerecord-6.1.4.1/ri/ActiveRecord/QueryMethods/includes-i.ri
U:RDoc::AnyMethod[iI"
includes:ETI"(ActiveRecord::QueryMethods#includes;TF:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"ASpecify relationships to be included in the result set. For ;TI"
example:;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [ I"%users = User.includes(:address)
;TI"users.each do |user|
;TI" user.address.city
;TI" end
;T:@format0o;
; [I"Nallows you to access the +address+ attribute of the +User+ model without ;TI"=firing an additional query. This will often result in a ;TI"0performance improvement over a simple join.;T@o;
; [I"<You can also specify multiple relationships, like this:;T@o;; [I"/users = User.includes(:address, :friends)
;T;
0o;
; [I";Loading nested relationships is possible using a Hash:;T@o;; [I"Fusers = User.includes(:address, friends: [:address, :followers])
;T;
0S:RDoc::Markup::Heading:
leveli: textI"conditions;T@o;
; [I"OIf you want to add string conditions to your included models, you'll have ;TI"/to explicitly reference them. For example:;T@o;; [I">User.includes(:posts).where('posts.name = ?', 'example')
;T;
0o;
; [I"-Will throw an error, but this will work:;T@o;; [I"QUser.includes(:posts).where('posts.name = ?', 'example').references(:posts)
;T;
0o;
; [I"NNote that #includes works with association names while #references needs ;TI"the actual table name.;T@o;
; [I"MIf you pass the conditions via hash, you don't need to call #references ;TI"Lexplicitly, as #where references the tables for you. For example, this ;TI"will work correctly:;T@o;; [I"<User.includes(:posts).where(posts: { name: 'example' });T;
0:
@fileI"0lib/active_record/relation/query_methods.rb;T:0@omit_headings_from_table_of_contents_below000[ I"(*args);T@BFI"QueryMethods;TcRDoc::NormalModule00