简体   繁体   English

延迟作业给出未定义的方法错误

[英]Delayed Job giving a undefined method error

Delayed job (2.1.4) is working perfectly on my development machine, sending emails with gay abandon - however it is failing miserably when running on my server using Apache/Passenger(3.0.7).延迟的工作(2.1.4)在我的开发机器上完美运行,发送带有同性恋遗弃的电子邮件 - 但是在使用 Apache/Passenger(3.0.7)在我的服务器上运行时它失败了。 Rails 3.0.7 and ruby 1.9.2 on both btw.顺便说一句,Rails 3.0.7 和 ruby 1.9.2。

I have seen that there is a problem when using thin where the job is created like this:我已经看到在创建作业的地方使用薄时存在问题,如下所示:

--- !ruby/struct:Delayed::PerformableMailer
object: !ruby/object:Class UserMailer

when it should read:什么时候应该读:

--- !ruby/struct:Delayed::PerformableMailer
object: !ruby/class UserMailer 

Mine are created correctly on my development machine, but the wrong way when created on the server.我的在我的开发机器上正确创建,但在服务器上创建时方法错误。

Has anyone else had this problem, where should I start looking?有没有其他人有这个问题,我应该从哪里开始寻找?

Stacktrace:堆栈跟踪:

{undefined method `standard_message' for #<Class:0xc6ad054>
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/performable_mailer.rb:6:in `perform'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/backend/base.rb:87:in `invoke_job'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in `block (2 levels) in run'\n
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/timeout.rb:57:in `timeout'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:120:in `block in run'\n
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:119:in `run'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:177:in `reserve_and_run_one_job'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:104:in `block in work_off'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in `times'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:103:in `work_off'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:78:in `block (2 levels) in start'\n
/usr/local/rvm/rubies/ruby-1.9.2-p180/lib/ruby/1.9.1/benchmark.rb:309:in `realtime'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:77:in `block in start'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in `loop'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/worker.rb:74:in `start'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/command.rb:104:in `run'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/command.rb:83:in `block in run_process'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:249:in `call'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:249:in `block in start_proc'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/daemonize.rb:199:in `call'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/daemonize.rb:199:in `call_as_daemon'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:253:in `start_proc'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/application.rb:293:in `start'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/controller.rb:70:in `run'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons.rb:195:in `block in run_proc'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/cmdline.rb:109:in `call'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons/cmdline.rb:109:in `catch_exceptions'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/daemons-1.1.3/lib/daemons.rb:194:in `run_proc'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/command.rb:81:in `run_process'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/command.rb:75:in `block in daemonize'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/command.rb:73:in `times'\n
/home/safrea/site/shared/bundle/ruby/1.9.1/gems/delayed_job-2.1.4/lib/delayed/command.rb:73:in `daemonize'\n
script/delayed_job:5:in `<main>'

I have managed to fix this.我设法解决了这个问题。

I created a setup_load_paths.rb a few weeks ago when bundler stopped working for some reason.几周前,当捆绑程序由于某种原因停止工作时,我创建了一个 setup_load_paths.rb。 This meant that the gemfile was being loaded everywhere, except by passenger.这意味着 gemfile 被加载到任何地方,除了乘客。 This messed up the call to YAML::ENGINE.yamler = "syck" which seems to be what mucked up the saving of the object.这弄乱了对 YAML::ENGINE.yamler = "syck" 的调用,这似乎破坏了 object 的保存。

I removed the setup_load_paths and everything is working nicely now.我删除了 setup_load_paths,现在一切正常。

If using the Syck parser doesn't seem to work (like mentioned in Marc's answer), try using the psych parser instead.如果使用 Syck 解析器似乎不起作用(就像 Marc 的回答中提到的那样),请尝试使用 psych 解析器。

YAML::ENGINE.yamler = "psych"

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM