chore: upgrade rails to 7.0 and other dependencies

This commit is contained in:
Adam Cooke
2024-02-23 22:51:37 +00:00
committed by Adam Cooke
parent cfc1c9b73e
commit ecd09a2445
27 changed files with 439 additions and 250 deletions
+10 -6
View File
@@ -35,12 +35,7 @@ class Webhook < ApplicationRecord
scope :enabled, -> { where(enabled: true) }
after_save :save_events
when_attribute :all_events, changes_to: true do
after_save do
webhook_events.destroy_all
end
end
after_save :destroy_events_when_all_events_enabled
def events
@events ||= webhook_events.map(&:event)
@@ -50,13 +45,22 @@ class Webhook < ApplicationRecord
@events = value.map(&:to_s).select(&:present?)
end
private
def save_events
return unless @events
@events.each do |event|
webhook_events.where(event: event).first_or_create!
end
webhook_events.where.not(event: @events).destroy_all
end
def destroy_events_when_all_events_enabled
return unless all_events
webhook_events.destroy_all
end
end