我通過resque發送電子郵件。所有電子郵件發送正確,除了這一個,它在本地發送罰款,但在登臺服務器上失敗。通過resque發送電子郵件:對象視爲散列
它似乎將'Admin'對象視爲散列而不是將其視爲管理對象。有任何想法嗎?
account.rb
class Account < ActiveRecord::Base
after_commit :send_welcome_email
def send_welcome_email
SubscriptionNotifier.welcome(self).deliver
end
end
subscription_notifier.rb
class SubscriptionNotifier < ActionMailer::Base
def welcome(account)
@subscriber = account
mail(:to => account.admin.email, :subject => "Welcome!")
end
end
Resque錯誤
SubscriptionNotifier Arguments
"welcome"
{"account"=>{"address_line1"=>nil, "address_line2"=>nil, "city"=>nil, "created_at"=>"2012-02-08T10:56:22-08:00", "currency"=>"United States Dollar (USD)", "deleted_at"=>nil, "description"=>nil, "email"=>"[email protected]", "full_domain"=>"www.test.net", "id"=>3, "initial_plan"=>nil, "latitude"=>nil, "longitude"=>nil, "name"=>"macs", "phone"=>nil, "setup_steps_complete"=>0, "state"=>nil, "time_zone"=>"Pacific Time (US & Canada)", "updated_at"=>"2012-02-08T10:56:22-08:00", "website"=>nil, "zip"=>nil}}
Exception
NoMethodError
Error
undefined method `admin' for #<Hash:0x0000000585aa70>
你用來實際調用'SubscriptionNotifier.welcome(...)。deliver'的代碼是什麼? – 2012-02-08 19:12:48
您可以添加Resque工人代碼並顯示您如何調用它? – bensie 2012-02-08 19:26:19
我更新了帖子。 Resque工作者代碼是subscription_notifier中的內容。這就好像Rails env沒有加載,但我用'rake resque:work QUEUE ='*'RAILS_ENV = staging' – 99miles 2012-02-08 19:51:34