-
-
Save paulcsmith/5826c700d9b2e491bc04bf461bb8a218 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Lucky will let you know at runtime that `comment.author` was not preloaded | |
CommentQuery.new.each do |comment| | |
p comment.author.name | |
end | |
# This will work since we preloaded the author | |
CommentQuery.new.preload_author.each do |comment| | |
p comment.author.name | |
end | |
# Use author! to skip preloading and skip raising the runtime error | |
CommentQuery.new.each do |comment| | |
p comment.author!.name | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment