mirror of
https://github.com/LaCasemate/fab-manager.git
synced 2025-02-19 13:54:25 +01:00
possible workaround for orphan InvoiceWorkers created with nil parameter
Moreover, a log was added on job creation, to help debugging if this does not fix the issue
This commit is contained in:
parent
e656b7d784
commit
ce7b737163
@ -13,7 +13,7 @@ class Invoice < ActiveRecord::Base
|
||||
has_one :avoir, class_name: 'Invoice', foreign_key: :invoice_id, dependent: :destroy
|
||||
|
||||
after_create :update_reference
|
||||
after_commit :generate_and_send_invoice, on: [:create]
|
||||
after_commit :generate_and_send_invoice, on: [:create], :if => :persisted?
|
||||
|
||||
def file
|
||||
dir = "invoices/#{user.id}"
|
||||
@ -204,6 +204,7 @@ class Invoice < ActiveRecord::Base
|
||||
|
||||
private
|
||||
def generate_and_send_invoice
|
||||
puts "Creating an InvoiceWorker job to generate the following invoice: id(#{id}), invoiced_id(#{invoiced_id}), invoiced_type(#{invoiced_type}), user_id(#{user_id})"
|
||||
InvoiceWorker.perform_async(id)
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user