my Film model has this:
:class_name => “Credit”,
:include => :credit_type,
:order => ‘credit_types.position,
:group => ‘credit_types.personnel_type’,
If I try and test this for emptiness:
if @film.live_action_personnel.size > 0
I get the following error:
MysqlError: Unknown table ‘credit_types’ in where clause: SELECT
count(*) AS count_all FROM credits WHERE (credits.film_id = 16 AND
but if I debug(@film.live_action_personnel) earlier within the same
template, all is well!
It seems that ActiveRecord isn’t generating the right query when I only
need to count the number of records.
Anyone know a way round this that doesn’t involve writing my own sql?