fix ArgumentError building routes on Rails 8.1 - #1496
Open
SAY-5 wants to merge 1 commit into
Open
Conversation
Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
This file contains hidden or 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
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.
All Submissions:
Bug fixes and Changes to Core Features:
Test Plan:
rake testneeds a database and currently errors out on a booted-app requirement inrails/test_helpthat's unrelated to this change (reproduces the same way on master with Rails 7.2 and 8.1, so it looks like a separate pre-existing gap in test_helper.rb's Rails 8 support). To verify this fix directly I installed actionpack 7.2.2.2 and 8.1.3.1 side by side and drew routes withjsonapi_resourcesthrough a realActionDispatch::Routing::RouteSet#draw, which is whattest/unit/routing_ext_test.rbdoes. That test errors with the exactArgumentError: wrong number of arguments (given 4, expected 3)from the issue when run against master, and passes on both Rails versions with this change.Reviewer Checklist:
Fixes #1488
Rails 8.1 changed
ActionDispatch::Routing::Mapper::Resource#initialize(andSingletonResource) to takeonly:/except:as keywords instead of a trailing positional options hash (rails/rails#53689).jsonapi_resource(s)still calls both with a plain positional hash, so drawing any route on Rails 8.1 raisesArgumentError: wrong number of arguments (given 4, expected 3)before the app boots. Passingoptionswith**instead of positionally works on both the old and the new signature.