0

我有一个按预期运行的延迟方法async_checkout_assist,它被添加到表中并毫无问题地执行,并在执行后从表中删除,但是在该延迟方法中,如果 condition_is_true 但是当我添加邮件行时,我想发送一封邮件它不发送邮件:\


class ApplicationController < ActionController::Base

  async = ApplicationController.new #create new instance
  async.async_checkout_assist #call method

  def async_checkout_assist
    Mailer.delay.mailer_checkout_assist(@contact_name, @contact_email, @contact_tel)
  end

  end
  handle_asynchronously :async_checkout_assist, :run_at => Proc.new { 10.seconds.from_now }

end

更新:

延迟方法(async_checkout_assist)被工人添加并运行

SQL (14.1ms)  INSERT INTO `delayed_jobs` (`attempts`, `created_at`, `failed_at`, `handler`, `last_error`, `locked_at`, `locked_by`, `priority`, `queue`, `run_at`, `updated_at`) VALUES (0, '2012-05-11 10:14:27', NULL, '--- !ruby/object:Delayed::PerformableMethod\nobject: !ruby/object:ApplicationController\n _routes: !!null \n _action_has_layout: true\n _headers:\n Content-Type: text/html\n _status: 200\n _request: !!null \n _response: !!null \nmethod_name: :async_checkout_assist_without_delay\nargs: []\n', NULL, NULL, NULL, 0, NULL, '2012-05-11 10:14:37', '2012-05-11 10:14:27')
   (17.2ms)  COMMIT


Marais-Mac-mini:cybercellar.com_heroku davidmuller$ rake jobs:work
[Worker(host:Marais-Mac-mini.local pid:886)] Starting job worker
[Worker(host:Marais-Mac-mini.local pid:886)] ApplicationController#async_checkout_assist_without_delay completed after 9.5160
[Worker(host:Marais-Mac-mini.local pid:886)] Class#mailer_checkout_assist completed after 7.3627
[Worker(host:Marais-Mac-mini.local pid:886)] 2 jobs processed at 0.0923 j/s, 0 failed ...

它现在适用于两者

Mailer.delay.mailer_checkout_assist(@contact_name, @contact_email, @contact_tel)
Mailer.mailer_checkout_assist(@contact_name, @contact_email, @contact_tel).deliver
4

0 回答 0