Skip to content

Commit

Permalink
fix serialize arguments for Rails 7.1+ (#179)
Browse files Browse the repository at this point in the history
  • Loading branch information
jprosevear authored Jul 23, 2024
1 parent dd8d681 commit 7709400
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion lib/activity_notification/orm/active_record/notification.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
6 changes: 5 additions & 1 deletion lib/activity_notification/orm/active_record/subscription.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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 }
Expand Down

0 comments on commit 7709400

Please sign in to comment.