Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add documentation for includes

  • Loading branch information...
commit d203a0e0b4f2a1959fb3dc486a5ee6684b44ccb3 1 parent aa43fa9
@oscardelben oscardelben authored
Showing with 11 additions and 0 deletions.
  1. +11 −0 activerecord/lib/active_record/relation/query_methods.rb
View
11 activerecord/lib/active_record/relation/query_methods.rb
@@ -41,6 +41,17 @@ def create_with_value
alias extensions extending_values
+ # Specify relationships to be included in the result set. For
+ # example:
+ #
+ # users = User.includes(:address)
+ # users.each do |user|
+ # user.address.city
+ # end
+ #
+ # allows you to access the +address+ attribute of the +User+ model without
+ # firing an additional query. This will often result in a
+ # performance improvement over a simple +join+
def includes(*args)
args.empty? ? self : spawn.includes!(*args)
end
Please sign in to comment.
Something went wrong with that request. Please try again.