I'm trying to get delayed job to work as a rake task, but for the life of me I can't figure out what I'm doing wrong. Given the following setup:
#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
Whenever I run rake jobs:clear I get the following error:
undefined method `handle_asynchronously' for SomeObserver:Class
Even though I don't get this error when I'm running the test cases or it directly. Any ideas?