나는 단순한 업적 시스템을 만들었고 처리를 위해 delayed_job (2.1.4)을 도입하려고했습니다. 그러나, delayed_jobs 테이블의 핸들러 열이 만약 Last_Error 텍스트에 어떤 결과 항상 nil 일 :Delayed_job (2.1.4) 오류 : 작업을로드하지 못했습니다. IO의 인스턴스가 필요합니다. 처리기 없음
성취 옵저버
class AchievementObserver < ActiveRecord::Observer
observe User, Comment, ...
def after_create(record)
# initiate delayed job to check conditions
Delayed::Job.enqueue(TrophyJob.new(record.id, record.class.name))
end
...
end
트로피 작업
: 여기Job failed to load: instance of IO needed. Handler nil
내 설정이다
class TrophyJob < Struct.new(:record_id, :record_type)
def perform
case record_type
when "User"
UserProfileCompleteTrophy.progress(User.find(record_id)) # complete your profile settings
NewsletterReceiverTrophy.progress(User.find(record_id)) # sign up for the newsletter
when "Comment"
CommentsAuthoredTrophy.progress(Comment.find(record_id)) # create x comments
...
end
end
end
delayed_jobs 테이블이 생성됩니다. 그러나 핸들러는 항상 NULL입니다. 나는 이미 여러 가지를 시도해 보았습니다. (예 : 완전한 객체를 통과했습니다. 여기에 설명 된대로 id + classname으로 이동했습니다 : Weird exception with delayed_job; xxxTrophy.delay.progress (...)를 관찰자에서 시도한 것 등) - 모두 운이 좋지 않습니다.
나는 또한 내 boot.rb.에
require 'yaml'
YAML::ENGINE.yamler= 'syck'
이
언급 할 가치가있는 한 가지 : last_error 텍스트가 delayed_job으로 채워지더라도 시도 및 failed_at 열은 NULL로 유지됩니다.
무엇이 누락 되었습니까?
UPDATE 나는 사람이 기대하는 것처럼 그 직렬화 작동 확인 :
ruby-1.9.2-p290 :004 > TrophyJob.new(1, "User").to_yaml
=> "--- !ruby/struct:TrophyJob \nrecord_id: 1\nrecord_type: User\n"
yaml 엔진 사용자 정의를 제거하려고 했습니까? – Nick
이 행은 YAML이 작동하는 데 필요합니다 (예 : 로케일). 나는 YAML 직렬화 문제로 인해 문제가 발생한 것으로 보았다는 것을 보여주기 위해 언급했지만, 이럴 가능성은 거의 없습니다. 그래도 고마워. – emrass