Damn Newbie! Multiple arguments to model method

Hi:

I’ve been working with rails for a couple of months now. And I was
getting pretty confident and feeling pretty good about how i was
proceeding. Every once in a while though, I try and do something that
keeps me humble, and reminds me that I’m still just a newbie.

Why doesn’t this work in my model:

def self.complete_task(tid, uid)
@taskhist = taskhist.new
@taskhist.task_id = gid
@taskhist.entity_id = uid
@taskhist.timeperiod_id = 7
@taskhist.task_meas = Taskhist.find(:first, :conditions => “task_id
= #{tid}”).goal_meas
@taskhist.taskhisttype_id = 3
@taskhist.save!
end

when I try and call from the console or from my controller. For some
reason, I get an argument 1 for 2 error. Can model methods only take 1
parameter in rails? If that’s the case, what’s my work around?

Thanks so much in advance!

Mike

On 2/19/07, Mike D. [email protected] wrote:

def self.complete_task(tid, uid)
when I try and call from the console or from my controller. For some
reason, I get an argument 1 for 2 error. Can model methods only take 1
parameter in rails? If that’s the case, what’s my work around?

Thanks so much in advance!

Hi Mike,

Take a look at the stack trace if you have one. There’s a lot of very
useful info in there normally. “1 for 2” means you’re giving
something 1 argument when it takes 2. Since you haven’t posted the
error message, I can’t tell what that method is, but I’ll take a wild
stab that you’re calling #complete_task with 1 argument, when it
appears to take 2.

Regards,
George.

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