-
Notifications
You must be signed in to change notification settings - Fork 61
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
Upgrade globalize to version 7.0 for Rails 7.2 support #153
Open
swamp09
wants to merge
1
commit into
solidusio-contrib:master
Choose a base branch
from
swamp09:upgrade_globalize_7.0
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
swamp09
added a commit
to swamp09/solidus
that referenced
this pull request
Jan 20, 2025
This PR modifies the Persistable module in Solidus to check the Rails version using Rails.gem_version instead of inspecting the serialize method parameters. This change is necessary only when using Solidus Globalize, ensuring compatibility with Rails 7.2. ## Background Solidus itself does not have any issues with the current implementation: ``` if method(:serialize).parameters.include?([:key, :type]) # Rails 7.1+ serialize :preferences, type: Hash, coder: YAML else serialize :preferences, Hash, coder: YAML end ``` However, when using Solidus Globalize, which relies on globalize, an issue arises in Rails 7.2 due to globalize overriding the serialize method: ``` ArgumentError: wrong number of arguments (given 2, expected 1) ``` This occurs because the serialize method signature is modified by globalize, causing a mismatch when Solidus inspects its parameters. For reference, see the globalize implementation here: https://github.com/globalize/globalize/blob/main/lib/patches/active_record/rails7_2/serialization.rb ## Solution To avoid conflicts, this PR replaces the method introspection with a Rails version check: ``` if Rails.gem_version >= Gem::Version.new('7.1') serialize :preferences, type: Hash, coder: YAML else serialize :preferences, Hash, coder: YAML end ``` This approach ensures compatibility while keeping Solidus independent from dependency-specific overrides. This issue is currently blocking the CI of the following PR in the solidus_globalize repository: solidusio-contrib/solidus_globalize#153 Fixing this in Solidus will help unblock that PR.
3 tasks
jarednorman
approved these changes
Jan 20, 2025
github-actions bot
pushed a commit
to solidusio/solidus
that referenced
this pull request
Jan 21, 2025
This PR modifies the Persistable module in Solidus to check the Rails version using Rails.gem_version instead of inspecting the serialize method parameters. This change is necessary only when using Solidus Globalize, ensuring compatibility with Rails 7.2. ## Background Solidus itself does not have any issues with the current implementation: ``` if method(:serialize).parameters.include?([:key, :type]) # Rails 7.1+ serialize :preferences, type: Hash, coder: YAML else serialize :preferences, Hash, coder: YAML end ``` However, when using Solidus Globalize, which relies on globalize, an issue arises in Rails 7.2 due to globalize overriding the serialize method: ``` ArgumentError: wrong number of arguments (given 2, expected 1) ``` This occurs because the serialize method signature is modified by globalize, causing a mismatch when Solidus inspects its parameters. For reference, see the globalize implementation here: https://github.com/globalize/globalize/blob/main/lib/patches/active_record/rails7_2/serialization.rb ## Solution To avoid conflicts, this PR replaces the method introspection with a Rails version check: ``` if Rails.gem_version >= Gem::Version.new('7.1') serialize :preferences, type: Hash, coder: YAML else serialize :preferences, Hash, coder: YAML end ``` This approach ensures compatibility while keeping Solidus independent from dependency-specific overrides. This issue is currently blocking the CI of the following PR in the solidus_globalize repository: solidusio-contrib/solidus_globalize#153 Fixing this in Solidus will help unblock that PR. (cherry picked from commit 2bcf076)
This PR updates the globalize dependency to ~> 7.0 to support Rails 7.2. https://github.com/globalize/globalize/releases/tag/v7.0.0
e3b6e89
to
fb95f5f
Compare
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR updates the globalize dependency to ~> 7.0 to support Rails 7.2.
https://github.com/globalize/globalize/releases/tag/v7.0.0