轨道上的ruby中未定义的类/模块

时间:2014-08-27 08:28:44

标签: ruby-on-rails-3 gem delayed-job

我在项目lib文件夹中创建了map_job.rb。但是为什么我在延迟工作时遇到这个错误。

  • 错误消息

    “last_error”:“作业无法加载:未定义的类/模块MapJob。处理程序:\”---!ruby / struct:MapJob \ nid:aa \ n \“\ n / app / vendor / bundle / ruby /1.9.1/gems/delayed_job-3.0.5/lib/delayed/backend/base.rb:87:in rescue in payload_object'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/backend/base.rb:85:in payload_object'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / backend / base.rb:95:在block in invoke_job'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:60:in调用'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib /delayed/lifecycle.rb:60:in block in initialize'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:65:in调用'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:65:在execute'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:38:in run_callbacks'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / backend / base.rb:92:in invoke_job'\n(eval):3:in块in invoke_job_with_newrelic_transaction_trace'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / newrelic_rpm-3.9.2.239 / lib / new_relic / agent / instrumentation / controller_instrumentation.rb:365:in perform_action_with_newrelic_trace'\n(eval):2:in invoke_job_with_newrelic_transaction_trace'\ n /app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:203:in block (2 levels) in run'\n/app/vendor/ruby-1.9.3/lib/ruby/1.9.1/timeout.rb:69:in timeout'\ n / app / vendor / bundle / ruby​​ / 1.9.1 /宝石/ delayed_job的-3。 0.5 / lib / delayed / worker.rb:203:在block in run'\n/app/vendor/ruby-1.9.3/lib/ruby/1.9.1/benchmark.rb:295:in实时'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / worker.rb :202:在run'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:259:in块中的reserve_and_run_one_job'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:60:in {{1初始化'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:65:在call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:60:in执行'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:38:in call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:65:in reserve_and_run_one_job'\ n / app / vendor / bundle / ruby​​ / 1.9 .1 / gems / delayed_job-3.0.5 / lib / delayed / worker.rb:187:run_callbacks'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:259:in次'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0。 5 / lib / delayed / worker.rb:186:在block in work_off'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:186:in块中(4级)开始'\ n / app / vendor / ruby​​-1.9.3 / lib / ruby​​ / 1.9.1 / benchmark.rb :295:在work_off'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:151:in块中(3级)开始'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:60:在realtime'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:150:in块初始化'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:65:在call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:60:in exe中可爱'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:38:in call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:65:in块(2级)开头'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / worker.rb:148:在开始'\ n / app / vendor / bundle中的run_callbacks'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:149:in块中'/ n / app / vendor / bundle / ruby​​中的/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/plugins/clear_locks.rb:7:in loop'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:148:in块(2级) /1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:78:in call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/plugins/clear_locks.rb:7:in阻止(2级)添加'\ n / app / vendor / bundle / ruby​​ / 1.9。 1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:60:in call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:78:in块初始化'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0 .5 / lib / delayed / lifecycle.rb:78:在call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:60:in块中添加'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:65:在call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:78:in执行'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / lifecycle.rb:38:in {{ 1}}启动'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / delayed_job-3.0.5 / lib / delayed / tasks.rb:9:在call'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/lifecycle.rb:65:in调用'\ n / app /vendor/bundle/ruby/1.9.1/gems /rake-10.3.2/lib/rake/task.rb:240:in run_callbacks'\n/app/vendor/bundle/ruby/1.9.1/gems/delayed_job-3.0.5/lib/delayed/worker.rb:147:in每个'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / rake-10.3.2 / lib / rake / task.rb:235:在block (2 levels) in <top (required)>'\n/app/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:240:in块中的invoke_with_call_chain'\ n / app / vendor / ruby​​-1.9.3 / lib / ruby​​ / 1.9.1 / monitor.rb:211:in {{1} } invoke_with_call_chain'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / rake-10.3.2 / lib / rake / task.rb:165:in block in execute'\n/app/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:235:in invoke_task'\ n / app / vendor /bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:106:in execute'\n/app/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:179:in每个'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / rake-10.3.2 / lib / rake / application.rb:106:in mon_synchronize'\n/app/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/task.rb:172:in run_with_threads'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / rake-10.3.2 / lib /rake/application.rb:100:in invoke'\n/app/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:150:in阻止运行'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / rake-10.3.2 / lib / rake / application.rb: 176:在block (2 levels) in top_level'\n/app/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:106:in运行'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / gems / rake-10.3.2 / bin / rake:33:in block in top_level'\n/app/vendor/bundle/ruby/1.9.1/gems/rake-10.3.2/lib/rake/application.rb:115:in load'\ n / app / vendor / bundle / ruby​​ / 1.9.1 / bin / rake:23:in''“,

请帮帮我。任何帮助将不胜感激!

2 个答案:

答案 0 :(得分:1)

您需要自动加载map_job.rb

在application.rb文件中执行此操作并重新启动服务器。

require "#{Rails.root.to_s}/lib/map_job.rb"

答案 1 :(得分:0)

你的map_job.rb文件中是否有一个名为MapJob的类/模块?错误抱怨您尚未定义具有该名称的类/模块