mirror of
https://github.com/ditkrg/outboxable.git
synced 2026-01-22 22:06:47 +00:00
Sets last_attempted_at at creation time to avoid null
This commit is contained in:
parent
723481af3d
commit
6793ac10c5
@ -2,9 +2,9 @@ class Outbox < ApplicationRecord
|
|||||||
attribute :allow_publish, :boolean, default: true
|
attribute :allow_publish, :boolean, default: true
|
||||||
|
|
||||||
# Callbacks
|
# Callbacks
|
||||||
after_commit :publish, if: :allow_publish?
|
before_create :set_last_attempted_at
|
||||||
before_save :check_publishing
|
before_save :check_publishing
|
||||||
|
after_commit :publish, if: :allow_publish?
|
||||||
# Enums
|
# Enums
|
||||||
enum status: { pending: 0, published: 1, failed: 2 }
|
enum status: { pending: 0, published: 1, failed: 2 }
|
||||||
enum size: { single: 0, batch: 1 }
|
enum size: { single: 0, batch: 1 }
|
||||||
@ -17,8 +17,7 @@ class Outbox < ApplicationRecord
|
|||||||
# Associations
|
# Associations
|
||||||
belongs_to :outboxable, polymorphic: true, optional: true
|
belongs_to :outboxable, polymorphic: true, optional: true
|
||||||
|
|
||||||
def increment_attempt
|
def set_last_attempted_at
|
||||||
self.attempts = attempts + 1
|
|
||||||
self.last_attempted_at = Time.zone.now
|
self.last_attempted_at = Time.zone.now
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user