From d627333af51814f57dee3eb3f654bce34607e0c5 Mon Sep 17 00:00:00 2001 From: JP Rosevear Date: Tue, 16 Jul 2024 20:46:46 -0400 Subject: [PATCH] fix serialize arguments for Rails 7.1+ --- lib/activity_notification/orm/active_record/notification.rb | 6 +++++- lib/activity_notification/orm/active_record/subscription.rb | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/lib/activity_notification/orm/active_record/notification.rb b/lib/activity_notification/orm/active_record/notification.rb index b654090e..ba73b520 100644 --- a/lib/activity_notification/orm/active_record/notification.rb +++ b/lib/activity_notification/orm/active_record/notification.rb @@ -45,7 +45,11 @@ class Notification < ::ActiveRecord::Base belongs_to :notifier, polymorphic: true, optional: true # Serialize parameters Hash - serialize :parameters, Hash + if Rails.gem_version >= Gem::Version.new('7.1') + serialize :parameters, type: Hash, coder: YAML + else + serialize :parameters, Hash + end validates :target, presence: true validates :notifiable, presence: true diff --git a/lib/activity_notification/orm/active_record/subscription.rb b/lib/activity_notification/orm/active_record/subscription.rb index 408cad4e..efa0ff4b 100644 --- a/lib/activity_notification/orm/active_record/subscription.rb +++ b/lib/activity_notification/orm/active_record/subscription.rb @@ -14,7 +14,11 @@ class Subscription < ::ActiveRecord::Base belongs_to :target, polymorphic: true # Serialize parameters Hash - serialize :optional_targets, Hash + if Rails.gem_version >= Gem::Version.new('7.1') + serialize :optional_targets, type: Hash, coder: YAML + else + serialize :optional_targets, Hash + end validates :target, presence: true validates :key, presence: true, uniqueness: { scope: :target }