Pretend I have a model, Post which has_many :comments. How can I only display posts that have comments?
I am somewhat comfortable with named_scope but I don't know how I can put Post.comments (or self.comments) in the :conditions hash which expects symbols.
class Post < ActiveRecord::Base
has_many :comments
named_scope :with_comments, :conditions => [#self.comments.length > 0]
end
What do I write in the commented area?
Thanks!