Find method not interpreting arguments correctly?

i’ve got a situtation where i’m trying to pass arguments from a method
to find and AR is telling me that it can’t find the record where
id=all

here’s what i am attempting to do

class Thing < ActiveRecord::Base
belongs_to :x
end

class FlyingThing < Thing
end

class x < ActiveRecord::Base
has_many :things do
def that_fly(*args)
FlyingThing.find(args)
end
end
end

so if i were to do

x.find(:first).things.that_fly(:all)

i get

ActiveRecord::RecordNotFound: Couldn’t find FlyingThing with ID=all

is this a bug or am i doing something wrong?

Chris

anyone got any ideas on this?

On Aug 18, 2006, at 5:27 AM, Chris H. wrote:

anyone got any ideas on this?

You need to splat the args into the find command. Try this:

class x < ActiveRecord::Base
has_many :things do
def that_fly(*args)
FlyingThing.find(*args)
end
end
end

-Ezra

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