Skip to content

Instantly share code, notes, and snippets.

@egrueter-dev
Created April 22, 2015 22:14
Show Gist options
  • Save egrueter-dev/544258ddd3cb8f8a4732 to your computer and use it in GitHub Desktop.
Save egrueter-dev/544258ddd3cb8f8a4732 to your computer and use it in GitHub Desktop.
Eliminating N+1 Queries
@purchases = current_user.purchases.includes(:charges)
#loads the charges for a particular user's purchases into memory, when you
#call the below code, the application does not need to go back to memory...
current_user.purchases.charges
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment