From d5ac83e0eb8dd23acc4880ecccfc720df0dd4f99 Mon Sep 17 00:00:00 2001 From: Diego Algorta Date: Thu, 16 Jan 2025 15:27:28 -0300 Subject: [PATCH] Resolve deprecations around serializtion for Rails 7.1 This commit just makes the code compatible with Rails 7.1 while preserving the original default behavior. --- lib/public_activity/orm/active_record/activity.rb | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/lib/public_activity/orm/active_record/activity.rb b/lib/public_activity/orm/active_record/activity.rb index 1f474a2..be26a25 100644 --- a/lib/public_activity/orm/active_record/activity.rb +++ b/lib/public_activity/orm/active_record/activity.rb @@ -47,7 +47,12 @@ class Activity < ::ActiveRecord::Base # Serialize parameters Hash begin if table_exists? - serialize :parameters, Hash unless [:json, :jsonb, :hstore].include?(columns_hash['parameters'].type) + case ::ActiveRecord::VERSION::MAJOR + when 7.. + serialize :parameters, type: Hash, coder: YAML unless [:json, :jsonb, :hstore].include?(columns_hash['parameters'].type) + else + serialize :parameters, Hash unless [:json, :jsonb, :hstore].include?(columns_hash['parameters'].type) + end else warn("[WARN] table #{name} doesn't exist. Skipping PublicActivity::Activity#parameters's serialization") end