ActiveRecord problems from within template


my Film model has this:

has_many :live_action_personnel,
:class_name => “Credit”,
:include => :credit_type,
:order => ‘credit_types.position,
credits.position ASC’,
:group => ‘credit_types.personnel_type’,
:conditions =>

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?





it appears that if I use
then all is ok.

My understanding is that this omits object caching of the sql, but I
can’t see why it would change the actual sql produced.
Might this be a bug?