Upgrade globalize to version 7.0 for Rails 7.2 support#153
Upgrade globalize to version 7.0 for Rails 7.2 support#153swamp09 wants to merge 1 commit intosolidusio-contrib:mainfrom
Conversation
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.
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
|
@jarednorman I saw you worked on globalize, is this obselete now or can we merge this? |
|
I don't know. I know there's some trickiness around supporting different versions of the globalize gem. I believe @harmonymjb was running into those issues. |
|
I think these content of commits that I added need to be removed with enforcing Globalize >= 7. They were added to allow support for Globalize 6 but in Globalize 7, it isn't needed. I don't think this is related to the test failures here though, those seem to be related to these 2 commits: solidusio/solidus@ce43cf9 I suspect your PR ran it's tests against main between these 2 commits, causing the mainfest related failure. |
|
@harmonymjb @jarednorman Globalize is not maintained anymore. Maybe it's easier for all of us if we move to mobility. It's a relatively straightforward migration. https://github.com/shioyama/mobility/wiki/Migrating-from-Globalize |
This PR updates the globalize dependency to ~> 7.0 to support Rails 7.2.
https://github.com/globalize/globalize/releases/tag/v7.0.0