Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix serialize arguments for Rails 7.1+ #179

Merged
merged 1 commit into from
Jul 23, 2024

Conversation

jprosevear
Copy link
Contributor

@jprosevear jprosevear commented Jul 17, 2024

Issue #178:

Summary

Rails deprecated passing the type as a second argument and no longer defaults to YAML as the default serializer:

https://github.com/rails/rails/blob/77dfa65392e672ac83ced68cda37d5770c16ea6c/activerecord/CHANGELOG.md?plain=1#L1262

https://github.com/rails/rails/blob/77dfa65392e672ac83ced68cda37d5770c16ea6c/activerecord/CHANGELOG.md?plain=1#L1282

Other Information

I did not realize this until I did config.load_defaults 7.1 . It may work in non-engine scenarios (see related rails issue rails/rails#52336), but this solves it for 7.1 and the upcoming 7.2

#173 original PR

@jprosevear jprosevear marked this pull request as draft July 17, 2024 00:49
@jprosevear jprosevear marked this pull request as ready for review July 17, 2024 01:24
@@ -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
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Based on reading the rails code and some tests, I believe YAML is the right selection

@simukappu
Copy link
Owner

LGTM

@simukappu simukappu merged commit 7709400 into simukappu:master Jul 23, 2024
21 checks passed
simukappu added a commit that referenced this pull request Jul 23, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants