delay_job:NoMethodError [英] delayed_job: NoMethodError

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

问题描述

这是我的小型Rails3控制器:

  class HomeController< ApplicationController 
def index
HomeController.delay.do_stuff
end
def self.do_stuff
放置 Hello
end
end

访问 index 后,作业将正确插入数据库中:

  ---!ruby / struct:Delayed :: PerformableMethod 
对象:!ruby / object:Class HomeController
method_name::do_stuff

问题:执行<$时c $ c> bundle exec rake jobs:work ,我得到:

  Class#do_stuff失败, NoMethodError:#b< Class:0x0000000465f910>的
未定义方法`do_stuff'

尽管 HomeController.do_stuff 起作用完美。有想法吗?

解决方案

请参见 https://github.com/collectiveidea/delayed_job/wiki/Common-problems#wiki-undefined_method_xxx_for_class 在文档中。



似乎您应该拥有



.. object:!ruby / class HomeController method_name ...



在数据库中,但是您有



.. object :! ruby / object:Class HomeController method_name ...





即使delay_job作者也不知道原因。它在某种程度上取决于您所运行的Web服务器。试试维基的建议。


Here is my tiny Rails3 controller:

class HomeController < ApplicationController
  def index
    HomeController.delay.do_stuff
  end
  def self.do_stuff
    puts "Hello"
  end
end

Upon accessing index, the job gets correctly inserted in database:

--- !ruby/struct:Delayed::PerformableMethod 
object: !ruby/object:Class HomeController
method_name: :do_stuff

PROBLEM: When executing bundle exec rake jobs:work, I get:

Class#do_stuff failed with NoMethodError:
    undefined method `do_stuff' for #<Class:0x0000000465f910>

Despite the fact that HomeController.do_stuff works perfectly. Any idea?

解决方案

See https://github.com/collectiveidea/delayed_job/wiki/Common-problems#wiki-undefined_method_xxx_for_class in documentation.

It seems that you should have

..object: !ruby/class HomeController method_name ...

in the database, but you have

..object: !ruby/object:Class HomeController method_name ...

instead. Which is bad.

Even delayed_job author don't know the reason. It somehow depends on the webserver you run in on. Try the wiki's recommendation.

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

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