내가 investment
가 venture
일일 전에서 investment
을 가지고있는 사용자의 수의 기록을 (유지하기 위해 만들어 질 때마다 일일하여 열 (yest_shareholder_count
)의 증가를 지연하기 위해 노력하고있어를 사용 증가 그래서이 데이터를 사용하여 시간이 지남에 따라 투자자의 수를 추적하는 그래프를 생성 할 수 있습니다.)delayed_job
이 작업을 수행하는 가장 간단한 방법은 delayed_job
이지만이 방법은 효과가 없다고 생각했습니다. delayed_job은 별도의 테이블에 만들어지고 SQLite DB Browser에 따라 하루 후 실행됩니다. 그러나 yest_shareholder_count 열이 증가하지 않습니다.
Venture
모델 :
def yest_increment
self.increment!(:yest_shareholder_count)
end
handle_asynchronously :yest_increment, :run_at => Proc.new {1.minute.from_now}
Investments
컨트롤러 :
def create
@venture = Venture.find(params[:share_id])
@venture_increment= @venture.increment(:shareholder_count)
@venture_yest_increment= @venture.yest_increment
@investment = current_user.invest!(@venture)
if @venture_increment.save and @venture_yest_increment.save
respond_to do |format|
format.html {redirect_to @venture}
end
end
end
똑 바른 증가가 일어난다는해야하지만, 지연 증가가하는 적이있다.
이
은 유용 단지 경우, delayed_jobs 테이블에서 "처리기"칼럼의 내용은 다음과 같습니다--- !ruby/struct:Delayed::PerformableMethod
object: !ruby/ActiveRecord:Venture
attributes:
created_at: 2011-06-21 07:00:12.252808
onemth_shareholder_count: 0
updated_at: 2011-08-09 16:50:36.864354
onewk_shareholder_count: 0
shareholder_count: 4
id: 49
user_id: 40
yest_shareholder_count: 0
method_name: :yest_increment_without_delay
args: []
나는 "yest_increment_without_delay"가 "에서 오는, 또는 왜 위치를 잘 모르겠어요 args "가 비어 있습니다.
도움을 주시면 감사하겠습니다.
편집 : 코드를 테스트하기 위해 "1.day.from_now"가 아닌 "1.minute.from_now"가 있습니다.
답변 주셔서 감사합니다. 문제는 값이 증가하지 않는다는 것입니다. – jonic
죄송합니다 - 이것은 명확하지 않았습니다. 그냥 질문을 편집했습니다. – jonic
'yest_increment'는 무엇을 반환해야합니까? 지연된 작업은 호출을 가로 채고 메소드를 호출하지 않으므로 리턴되지 않습니다. 콘솔에서'yest_increment_without_delay'를 올바르게 호출 했습니까? – rubish