0
我有位於/lib/jobs/MessageNotificationJob.rb
的delayed_job - NameError - uninitilized不斷
class MessageNotificationJob < Struct.new(:user_id, :message_id)
def perform
@user = User.find(user_id)
@message = Message.find(message_id)
if !message.reciever_open
MessagesMailer.message_notification(@user, @message).deliver
end
end
end
這個自定義的工作,我有
Delayed::Job.enqueue(MessageNotificationJob.new(@user.id, @msg.id))
在我application.rb
調用它從MessagesController
的方法我有
config.autoload_paths += Dir["#{config.root}/lib/**/"]
但我得到錯誤
NameError - uninitialized constant MessagesController::MessageNotificationJob:
我該如何解決這個問題?我已經嘗試了幾個變體,將其作爲解決類似問題的最新解決方案。我錯過了什麼?
正如我想到的,我很確定這是問題所在。符號引用來自YAML.load()或等價物,因此只需將MessageNotificationJob添加到自動加載列表中即可。 – 2013-02-19 06:37:01