I have posts that are associated with comments. I want to create an array of comments from the first 10 posts. I had the following method but to_a seems to not work anymore? Also will this give an N+1 query? should I do includes(:comments) to preload them?
def 10_posts_comments
posts = Post.limit(10)
posts.flat_map do |post|
post.comments.to_a
end
end
I'm still new at this so any help appreciated.