我正试图让延迟的工作成为一项繁重的任务,但对于我的生活,我无法弄清楚我做错了什么。鉴于以下设置:
#config/environment.rb
Rails::Initializer.run do |config|
config.gem 'delayed_job'
end
#Rakefile
begin
require 'delayed/tasks'
rescue LoadError
STDERR.puts "Run `rake gems:install` to install delayed_job"
end
#Observer
class SomeObserver < ActiveRecord::Observer
def foo(bar)
end
handle_asynchronously :foo
end
每当我运行 rake jobs:clear 时,都会出现以下错误:
undefined method `handle_asynchronously' for SomeObserver:Class
即使我在运行测试用例或直接运行测试用例时没有收到此错误。有任何想法吗?