Problem with built-in named scope all


I’m having a problem with the built-in all scope. For example in my
Subscription model,

NoMethodError: undefined method `count’ for #Array:0xb5dce7f8
from (irb):46
from :0

However, my own version of all defined in the model simply as
“named_scope :everything” works fine

=> 849

I also cannot chain scopes onto all
NoMethodError: undefined method `active’ for #Array:0xb5a80268
from (irb):50
from :0

=> 611

I’m relatively new to Rails so any insights people can give would be
greatly appreciated. Thanks!

My environment is

[root@localhost trunk]# gem -v
[root@localhost trunk]# gem list

*** LOCAL GEMS ***

actionmailer (2.1.0)
actionpack (2.1.0)
activerecord (2.1.0)
activeresource (2.1.0)
activesupport (2.1.0)
mysql (2.7)
piston (1.4.0)
rails (2.1.0)
rake (0.8.1)
[root@localhost trunk]# cat /etc/issue
CentOS release 5.2 (Final)
Kernel \r on an \m
[root@localhost trunk]# uname -a
Linux localhost.localdomain 2.6.18-92.1.6.el5 #1 SMP Wed Jun 25
13:49:24 EDT 2008 i686 i686 i386 GNU/Linux

On Jul 28, 11:19 am, cah4i [email protected] wrote:

Since .all internally is doing a find(:all), it’s returning an array,
not an proxy like named_scope and the association methods do. So
although it might look like a named scope, it actually isn’t.

So instead of Subscription.all.count, you have to do
Subscription.count. Instead of, just do Having the “all” in there is redundant
anyway, although I sympathize with the concept that it might feel more
consistent that way.