Skip to content

Instantly share code, notes, and snippets.

@saidM
Last active August 29, 2015 14:18
Show Gist options
  • Save saidM/e38f6d572885db0c61d2 to your computer and use it in GitHub Desktop.
Save saidM/e38f6d572885db0c61d2 to your computer and use it in GitHub Desktop.
lazy loading
books = Book.all.limit(10) # Charge les books présents dans notre database (1 requête SQL)
books.each do |book|
puts book.author.name # Pour chaque livre, effectue une requête SQL pour récupérer le nom de l'auteur
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment