<[email protected]>I am trying to send email as a background
process from within a Rails app.

The goal is that when I go to http://mysite.com/foo/bar, the background job
kicks in and sends an email out. The relevant code snippets are below.

This errors out with a wrong number of arguments passed (2 for 1) message. I
think I am making a mess of passing parameters to the email_admin method in
the worker. How should I be passing multiple parameters to email_admin?

Thanks

==============================
# Worker Code
class PostalWorker < BackgrounDRb::MetaWorker

  set_worker_name :postal_worker

  def create
    # this method is called, when worker is loaded for the first time
  end

  def email_admin(p_subject,p_body)
    Emailer.deliver_send_info(p_subject,p_body,Time.now)
  end

end
==============================
# Rails controller code
class FooController < ApplicationController

def bar
      worker = MiddleMan.worker(:postal_worker)
      result = worker.email_admin('Some subject','And some body')
      render :text => "Check your email " + Time.now.to_s
end
================================
# Rails nodel code
class Emailer < ActionMailer::Base

  def send_info(subject,message,sent_at = Time.now)
    @subject    = subject
    @body       = {:message => message}
    @recipients = '[EMAIL PROTECTED]'
    @from       = ''
    @sent_on    = sent_at
    @headers    = {}
  end

end
======================================
_______________________________________________
Backgroundrb-devel mailing list
[email protected]
http://rubyforge.org/mailman/listinfo/backgroundrb-devel

Reply via email to