I have mongoid model
class RequestResponse
include Mongoid::Document
field :body, type: String
field :job_id, type: Fixnum
field :completed, type: Boolean
end
and according to rails cast I have a class in my lib folder
class MyJob < Struct.new(:session, :url, :r_id)
def perform
rr = RequestResponse.find(r_id)
session = YAML.load session
rr.body = session.get(url).body
rr.completed = true
rr.save
end
end
I called some where in my controller
rr = RequestResponse.new
rr.save
Delayed::Job.enqueue(MyJob.new(session.to_yaml, url, rr.id),3)
I can see with
rake jobs:work
1 jobs processed at 19.3392 j/s, 0 failed ...
And the result is not stored in the table for rr if i check
rr.body
it is still nill any one can help me out Thanks in advance