I have a User model that has_many: posts. If I wanted to make named_scope to search for users with at least one message, would that be correct?
named_scope :at_least_one_post, :joins => :posts, :group => "users.id"
or should I take one more step and take
named_scope :at_least_one_post, :joins => :posts, :group => "users.id", :having => "COUNT(posts.id) > 0"
source
share