Delayed::Job with modules

我的梦境 提交于 2019-12-22 00:05:35

问题


Does Delayed::Job work with modules? I have trouble with it:

module SomeModule
  class SomeClass
     def regular_method
       self.delay.long_method "test"
     end

     def long_method data
       puts data
     end
  end
end

Error message:

[Worker(host:leo pid:10480)] SomeModule::SomeClass#long_method failed with NoMethodError: undefined method `long_method' for #<YAML::Object:0xcee13b0 @class="SomeModule::SomeClass", @ivars={}> - 4 failed attempts
[Worker(host:leo pid:10480)] 1 jobs processed at 9.1484 j/s, 1 failed ...

回答1:


This problem in rails class auto loading. Just add

require "#{Rails.root}/app/models/some_module/some_class"

to initializers or environment.rb



来源:https://stackoverflow.com/questions/4467527/delayedjob-with-modules

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!