我有一个模型,其中包含以下内容:
def fetch_austlii
Resque.enqueue(FetchAustliiJob, self.id) # Queue the job for later.
end
这将调度 app/workers/fetch_austlii_job.rb 文件:
class FetchAustliiJob
@queue = :fetch_queue
def self.perform(profile_id)
@profile = Profile.find(profile_id)
AustliiResource.fetch(@profile.name).each do |resource|
@profile.austlii_resources.create!(resource.attributes) if @profile.austlii_resources.find_all_by_url(resource.url).empty?
end
end
end
在开发中(OS X、Ruby 1.9.2、Rails3、Postgres、Redis-server、Foreman)它工作正常。这项工作就像它应该从互联网上检索信息一样。但是,在生产中(Ubuntu、Ruby 1.9.2、Passenger)它失败了:
Class
FetchAustliiJob
Arguments
2
Exception
NoMethodError
Error
undefined method `austlii_resources' for #<Profile:0x00000002fab6b0>