fix: Update associations when a label is updated (#3046)
This commit is contained in:
@@ -25,6 +25,8 @@ class Label < ApplicationRecord
|
||||
format: { with: UNICODE_CHARACTER_NUMBER_HYPHEN_UNDERSCORE },
|
||||
uniqueness: { scope: :account_id }
|
||||
|
||||
after_update_commit :update_associated_models
|
||||
|
||||
before_validation do
|
||||
self.title = title.downcase if attribute_present?('title')
|
||||
end
|
||||
@@ -40,4 +42,12 @@ class Label < ApplicationRecord
|
||||
def events
|
||||
account.events.where(conversation_id: conversations.pluck(:id))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def update_associated_models
|
||||
return unless title_previously_changed?
|
||||
|
||||
Labels::UpdateJob.perform_later(title, title_previously_was, account_id)
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user