Skip to content

fix ArgumentError building routes on Rails 8.1 - #1496

Open
SAY-5 wants to merge 1 commit into
JSONAPI-Resources:masterfrom
SAY-5:fix-rails-8-1-resource-argumenterror
Open

fix ArgumentError building routes on Rails 8.1#1496
SAY-5 wants to merge 1 commit into
JSONAPI-Resources:masterfrom
SAY-5:fix-rails-8-1-resource-argumenterror

Conversation

@SAY-5

@SAY-5 SAY-5 commented Aug 25, 2026

Copy link
Copy Markdown

All Submissions:

  • I've checked to ensure there aren't other open Pull Requests for the same update/change.
  • I've submitted a ticket for my issue if one did not already exist.
  • My submission passes all tests. (Please run the full test suite locally to cut down on noise from travis failures.)
  • I've used Github auto-closing keywords in the commit message or the description.
  • I've added/updated tests for this change.

Bug fixes and Changes to Core Features:

  • I've included an explanation of what the changes do and why I'd like you to include them.
  • I've provided test(s) that fails without the change.

Test Plan:

rake test needs a database and currently errors out on a booted-app requirement in rails/test_help that'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 with jsonapi_resources through a real ActionDispatch::Routing::RouteSet#draw, which is what test/unit/routing_ext_test.rb does. That test errors with the exact ArgumentError: 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:

  • Maintains compliance with JSON:API
  • Adequate test coverage exists to prevent regressions

Fixes #1488

Rails 8.1 changed ActionDispatch::Routing::Mapper::Resource#initialize (and SingletonResource) to take only:/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 raises ArgumentError: wrong number of arguments (given 4, expected 3) before the app boots. Passing options with ** instead of positionally works on both the old and the new signature.

Signed-off-by: Sai Asish Y <say.apm35@gmail.com>
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.

ArgumentError with Rails 8.1

1 participant