From c21e447a78af1cce7687f8824fd3b60ab2046081 Mon Sep 17 00:00:00 2001 From: Phuoc Nguyen Date: Wed, 29 Mar 2017 01:09:30 +1100 Subject: [PATCH] prevent action from running again if there is a commit in action --- lib/after_commit_queue.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/after_commit_queue.rb b/lib/after_commit_queue.rb index 8fa7286..a4f5cfa 100644 --- a/lib/after_commit_queue.rb +++ b/lib/after_commit_queue.rb @@ -18,7 +18,8 @@ def run_after_commit(method = nil, &block) # Protected: Is called as after_commit callback # runs methods from the queue and clears the queue afterwards def _run_after_commit_queue - _after_commit_queue.each do |action| + while _after_commit_queue.present? + action = _after_commit_queue.pop self.instance_eval &action end @after_commit_queue.clear