I have a question about HABTM and counting records.
I have these models
class Sort < ActiveRecord::Base
class Report < ActiveRecord::Base
And i would like to get a count like
The problem is get this query:
SELECT COUNT(*) FROM reports WHERE (reports_sorts.sort_id = 6003 )
He uses the wrong table “reports” instead of the join table
“reports_sorts”. But it is in the where clause.
Thanks in advance,