This should work:
comments = Comment.joins(:user).includes(:user)
But here is what I think happens if you view the output in your console windows, I think that the output to the console reflects / checks the returned root level object.
I just did an experiment where I executed the above code. The terminal output says that he received comments, but did not mention the associated user. Then I complete the database so that the second query could not be executed against the database, and then asked the associated user, for example.
comments.user
The console displays the user, which proves that it has already been loaded, because the connection to the database has not been attempted.
Scott
source share