Hi,
Im using the count calculations in activerecord, see below
self.count(:id, :include => [:operating_systems], :group => 'operating_systems.name, operating_systems.id',
This only returns 2 of the fields i need the id and the count:
count_id operating_systems_name_operating_systems_id 49 1 30 2
If i run the sql this generates in the log on the database itself i get the follwoing
SELECT count(DISTINCT "products".id) AS count_id, operating_systems.name, operating_systems.id AS operating_systems_name_operating_systems_id FROM "products" LEFT OUTER JOIN "product_operating_systems" ON ("products"."id" = "product_operating_systems"."product_id") LEFT OUTER JOIN "operating_systems" ON ("operating_systems"."id" = "product_operating_systems"."operating_system_id") GROUP BY operating_systems.name, operating_systems.id
So the above sql run on the DB i get 3 columns with the required information:
count_id name operating_systems_name_operating_systems_id 49 PC 1 30 MAC 2
Is there any reason for this? Anybody got a better solution?
JB