diff --git a/lib/activity_notification/orm/active_record/notification.rb b/lib/activity_notification/orm/active_record/notification.rb index b654090..66d542b 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, coder: Hash + 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 408cad4..1a990c3 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, coder: Hash + else + serialize :optional_targets, Hash + end validates :target, presence: true validates :key, presence: true, uniqueness: { scope: :target }