ActiveRecord find :select

Hello,

Why using this :select, it works :

:select=>", (select count() from tasks T) as subcache"

but using this one does not:

:select=>", (select count() from tasks T where T.task_id =
tasks.id) as subcache"

returning this error:

ActionView::TemplateError (undefined method `subcache’ for
#Task:0xb706bc30) on line #6 of task/_task_c.rhtml:
6: <% nb = task_c.subcache.to_i %>

I have tested this query in MySQL Query Broser and it is well formed and
works.
select , (select count() from tasks T where T.task_id = tasks.id) as
subcache from tasks

Thanks,
Mickael.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs