带模块的延迟:: Job [英] Delayed::Job with modules

查看:57
本文介绍了带模块的延迟:: Job的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Delayed :: Job是否可以与模块一起使用?
我有麻烦:

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

错误消息:

[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 ...


推荐答案

rails类自动加载中的此问题。只需添加

This problem in rails class auto loading. Just add

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

到初始化程序或environment.rb

to initializers or environment.rb

这篇关于带模块的延迟:: Job的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆