true, but this doesn't help in this specific case where I need to count hosts based on different conditions.
on the same matter, it was quite easy to count with :group on associations like has_many, but it seems not to work on habtm relationships, e.g.
user has and belongs to many groups
what do I need to do to know how many users belongs to each group?
my current code (which works but really ugly) is something like this:
User.count_habtm "group"
def self.count_habtm association
output = {}
self.count(:include => association.pluralize, :group => "#{association}_id").to_a.each do |a|
#Ugly Ugly Ugly - I guess I'm missing something basic here
label = eval(association.camelize).send("find",a[0].to_i).to_label if a[0]
output[label] = a[1]
end
output
end
Thanks,
Ohad