执行SampleController时出现以下错误。
uninitialized constant IdeasController::Delayed
我已经使用rake jobs启动了delayed_job:work。我在SampleController.rb中有以下delayed_job代码
Delayed::Job.enqueue(DelayedWorker.new({:model=>object.class.to_s,:object_id=>object.id,:meth=>:create_suggestion}))
delayed_worker.rb包含以下代码:
class DelayedWorker < Struct.new(:options)
def perform
if obj=Object.const_get(options[:model]).find(options[:object_id])
if (options[:para] ? obj.send(options[:meth],options[:para].first) : obj.send(options[:meth]))
puts "Successfull"
else
puts "Failed"
end
end
end
end
任何人请帮我解决这个问题。
...谢谢
答案 0 :(得分:0)
更改
Delayed::Job.enqueue(DelayedWorker.new({:model=>object.class.to_s,:object_id=>object.id,:meth=>:create_suggestion}))
到
::Delayed::Job.enqueue(DelayedWorker.new({:model=>object.class.to_s,:object_id=>object.id,:meth=>:create_suggestion}))