Named_scope returns Array -- find returns error?

From the documentation:

class Shirt < ActiveRecord::Base
named_scope :red, :conditions => {:color => ‘red’}

Unlike Shirt.find(…), however, the object returned by is not
an Array; it resembles the association object constructed by a has_many
declaration. For instance, you can invoke,,, :conditions => {:size => ‘small’})

So, …) is valid according to the docs.

I have:

class Member < ActiveRecord::Base
named_scope :active_members, :conditions => { :rcrd_status => ‘Y’ }

And wish to call:
Member.active_members.find(:all, :conditions => { … })

But I’m getting the error:

ArgumentError (wrong number of arguments (2 for 1)): in `find’

And I noticed Member.active_members.class.to_s returns “Array”

What gives? I can’t imagine the documentation being that wrong, so
what did I do wrong?

On 19 July 2010 23:35, Seth W. [email protected] wrote:

declaration. For instance, you can invoke,
class Member < ActiveRecord::Base

ArgumentError (wrong number of arguments (2 for 1)): in `find’

Can you show us the exact line that fails please with a few lines each
side, with line numbers, and the trace dump?

What happens if you use active_members without the find?


It’s a pity there’s no way to delete threads here. It turned out I had a
class method with the same name. slaps forehead. Typical. Spend
forever finding a bug, ask for help, find the answer yourself soon
after! Sorry for the noise.

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