Skip to content

Commit 9fd84fd

Browse files
committed
Allow omitting a block, which will just enqueue an empty job
1 parent 63407f6 commit 9fd84fd

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

app/models/solid_queue/batch.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@ class Batch < Record
55
include Trackable
66

77
has_many :jobs, foreign_key: :batch_id, primary_key: :batch_id
8-
has_many :batch_executions, foreign_key: :batch_id, primary_key: :batch_id, class_name: "SolidQueue::BatchExecution"
8+
has_many :batch_executions, foreign_key: :batch_id, primary_key: :batch_id, class_name: "SolidQueue::BatchExecution",
9+
dependent: :destroy
910

1011
serialize :on_finish, coder: JSON
1112
serialize :on_success, coder: JSON
@@ -25,7 +26,7 @@ def enqueue(&block)
2526
save! if new_record?
2627

2728
Batch.wrap_in_batch_context(batch_id) do
28-
block.call(self)
29+
block&.call(self)
2930
end
3031

3132
if ActiveRecord.respond_to?(:after_all_transactions_commit)

0 commit comments

Comments
 (0)