Skip to content

Commit

Permalink
Resolve deprecations around serializtion for Rails 7.1
Browse files Browse the repository at this point in the history
This commit just makes the code compatible with Rails 7.1 while preserving the original default behavior.
  • Loading branch information
oboxodo committed Jan 16, 2025
1 parent 6a02ece commit d5ac83e
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/public_activity/orm/active_record/activity.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit d5ac83e

Please sign in to comment.