2012-09-27 29 views
1

提供我在我的報告控制器這種方法:無法用delayed_job的

def send_status 
date = Date.today 
reports = current_user.reports.for_date(date) 
ReportMailer.status_email(current_user, reports, date).deliver 
reports.update_all(:sent_mail => true) 
head :ok 
rescue => e 
render text: e.message, status: :bad_request 
end 

發送此狀態時,所以我用的delayed_job我不能做任何要求,更換

ReportMailer.status_email(CURRENT_USER,報告,日期).deliver與 ReportMailer.status_email(current_user,報表,日期).send_later(:send_status)

但我得到400個不良請求delivery.Any幫助嗎?謝謝!

+0

這將有助於如果確切的錯誤堆棧跟蹤是已知的。而不是一個全面的救援聲明,使用特定的錯誤類,以避免在調試時出現歧義。如果您移除救援區塊,您會得到什麼錯誤? – Kashyap

+0

完成500內部服務器錯誤在24MS 類型錯誤(不能傾倒匿名模塊:#<模塊:0xc9c9cc4>): 應用程序/控制器/ reports_controller.rb:97:在'SEND_STATUS' –

+0

我還試圖ReportMailer.delay。 status_email(current_user,報告,日期) –

回答

2

避免將對象的delayed_job和使用IDS來代替:(您delayed_job的進程可能會默默地失敗)

ReportMailer.delay.status_email(current_user.id, reports_ids, date) 

而且裏面status_email,拉CURRENT_USER和報告:

def status_email(userid, reports_ids, date) 
    current_user = User.find_by_id(userid) 
    reports = Report.find_all_by_id(reports_ids) 
    ... 
end