Permalink
Browse files

fix delayed_job functionality

  • Loading branch information...
edtsech committed Nov 4, 2009
1 parent 12c5213 commit 4daf742a7f84c53ae683358b4c1d27b6e0b131e4
Showing with 14 additions and 1 deletion.
  1. +9 −0 db/migrate/002_add_delayed_job_id_to_issue.rb
  2. +5 −1 lib/issue_closed.rb
@@ -0,0 +1,9 @@
+class AddDelayedJobIdToIssue < ActiveRecord::Migration
+ def self.up
+ add_column :issues, :delayed_job_id, :integer
+ end
+
+ def self.down
+ remove_column :issues, :delayed_job_id
+ end
+end
View
@@ -60,7 +60,11 @@ def edit
status_before_update != @issue.status and \
@issue.status.state == false
- Delayed::Job.enqueue DelayedClose.new(@issue.id), 0, 7.days.from_now
+ Delayed::Job.destroy(@issue.delayed_job_id) unless @issue.delayed_job_id == nil
+ job = Delayed::Job.enqueue DelayedClose.new(@issue.id), 0, 7.days.from_now
+
+ @issue.delayed_job_id = job.id
+ @issue.save
end
end
end

0 comments on commit 4daf742

Please sign in to comment.