是否可以像这样优化参数化案例:
class Post
belongs_to :author
has_many :comments
end
class Comment
belongs_to :author
belongs_to :post
scope :from, -> (author) { where(author: author) }
end
class Author
has_many :posts
has_many :comments
end
author = Author.find(42)
author.posts.each do |post|
if post.comments.from(author).any?
puts post.inspect
end
end