Skip to content

Instantly share code, notes, and snippets.

@AntelopeSalad
Created January 20, 2014 20:46
Show Gist options
  • Save AntelopeSalad/8528791 to your computer and use it in GitHub Desktop.
Save AntelopeSalad/8528791 to your computer and use it in GitHub Desktop.
includes(*args) public
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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment