hi Guys

I have now spent hours on this and turn to you in desperation.

I am using Actionmailer to fetch emails, but I need to pass a userid to
the receive method, so that the receive method knows what user to pass
the email to. I tried:
(ATTEMPT 1)
class PokeMailer < ActionMailer::Base
  def receive(email,userid)
    ...
  end

I then invoke the receipt of email with

task = PokeMailer.receive(m.pop,userid)

But I get the error 'wrong number of arguments (2 for 1)'

So I though - ok - the actionmailer receive method must be expecting one
argument. Lets create another method to accept the userid and call the
receive method with only the raw email. So I wrote as second PokeMailer
method:
(ATTEMPT 2)
class PokeMailer < ActionMailer::Base
  def getemail(email,userid)
    @userid=userid
    PokeMailer.receive(email)
  end
  def receive(email)
    ..
  end
  ..
end

and call it with

task = PokeMailer.getemail(m.pop,userid)

Now I get the error 'undefined method `getemail' for PokeMailer:Class'

(kindof figured this out - changed def getemail to def self.getemail

My third attempt was to try and instantiate an instance of PokeMailer
with a initialize method:
(ATTEMPT 3)
class PokeMailer < ActionMailer::Base
  def intitalize (userid)
    @userid = userid
    super #not sure if this is needed?
  end
  def receive(email)
    ...
  end
  ...
end

and then call this with something like:

pm = PokeMailer.new(userid)
task = pm.receive(m.pop)

This fails because it seems that pm == nil - it doesn't event get
created?!!!

I am at whits' end. Please save me!

Thanks for anything - even sympathy would help ;)

Pieter Hugo

-- 
Posted via http://www.ruby-forum.com/.

-- 
You received this message because you are subscribed to the Google Groups "Ruby 
on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en.

Reply via email to