Active Record includes and N + 1 Query Problem
Consider the following code books = Book.limit(10) books.each do |book| puts book.author.last_name end In the above code, a query is made each time the lastname of an author of a book is needed in puts book.author.last_name. A single query for each book.…