Skip to content

Commit a873454

Browse files
takaokoujiclaude
andcommitted
Add partial Rails 8.1.1 support (664/674 tests passing)
Fix Rails 8.1 routing API breaking changes for Resource and SingletonResource initialization. Key Changes: 1. Routing API Update (Rails 8.1): - Rails 8.1 changed Resource.new and SingletonResource.new signatures - Removed 4th parameter (options) from both constructors - Updated signatures: * Before: Resource.new(type, api_only, shallow, options) * After: Resource.new(type, api_only, shallow) - Add version-conditional logic in routing_ext.rb: * Rails 8.1+: Use 3-argument constructor * Rails < 8.1: Use 4-argument constructor Files Modified: - lib/jsonapi/routing_ext.rb: * Fixed Resource.new call (line ~138) * Fixed SingletonResource.new call (line ~64) Test Results: - Rails 6.1.7.10: ✅ 674/674 tests passing - Rails 7.0.10: ✅ 674/674 tests passing - Rails 7.1.6: ✅ 674/674 tests passing - Rails 7.2.3: ✅ 674/674 tests passing - Rails 8.0.4: ✅ 674/674 tests passing - Rails 8.1.1: ⚠️ 664/674 tests passing (10 failures) Rails 8.1 Remaining Issues (10 test failures): 1. JoinTreeTest: SQL generation issue (1 failure) 2. RequestTest: Relationship route 404 errors (5 failures) 3. RequestTest: JSON parse error message format change (4 failures) All backward compatibility maintained for Rails 6.1-8.0. Rails 8.1 is partially supported pending investigation of remaining failures. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent fa750db commit a873454

File tree

3 files changed

+18
-4
lines changed

3 files changed

+18
-4
lines changed

lib/jsonapi/routing_ext.rb

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,15 @@ def jsonapi_resource(*resources, &_block)
5858
jsonapi_relationships
5959
end
6060
else
61-
# Rails 5
62-
jsonapi_resource_scope(SingletonResource.new(@resource_type, api_only?, @scope[:shallow], options), @resource_type) do
61+
# Rails 5+
62+
# Rails 8.1 changed SingletonResource.new to accept only 3 arguments (removed options)
63+
resource_arg = if Rails::VERSION::MAJOR >= 8 && Rails::VERSION::MINOR >= 1
64+
SingletonResource.new(@resource_type, api_only?, @scope[:shallow])
65+
else
66+
SingletonResource.new(@resource_type, api_only?, @scope[:shallow], options)
67+
end
68+
69+
jsonapi_resource_scope(resource_arg, @resource_type) do
6370
if block_given?
6471
yield
6572
else
@@ -132,8 +139,15 @@ def jsonapi_resources(*resources, &_block)
132139
jsonapi_relationships
133140
end
134141
else
135-
# Rails 5
136-
jsonapi_resource_scope(Resource.new(@resource_type, api_only?, @scope[:shallow], options), @resource_type) do
142+
# Rails 5+
143+
# Rails 8.1 changed Resource.new to accept only 3 arguments (removed options)
144+
resource_arg = if Rails::VERSION::MAJOR >= 8 && Rails::VERSION::MINOR >= 1
145+
Resource.new(@resource_type, api_only?, @scope[:shallow])
146+
else
147+
Resource.new(@resource_type, api_only?, @scope[:shallow], options)
148+
end
149+
150+
jsonapi_resource_scope(resource_arg, @resource_type) do
137151
if block_given?
138152
yield
139153
else

test/test_db-shm

-32 KB
Binary file not shown.

test/test_db-wal

-3.93 MB
Binary file not shown.

0 commit comments

Comments
 (0)