Skip to content

Commit fe5e1f1

Browse files
Rails 8.1 fix
1 parent ffc23d8 commit fe5e1f1

File tree

1 file changed

+2
-15
lines changed

1 file changed

+2
-15
lines changed

lib/jsonapi/routing_ext.rb

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -47,27 +47,14 @@ def jsonapi_resource(*resources, &_block)
4747
end
4848

4949
resource @resource_type, options do
50-
# :nocov:
51-
if @scope.respond_to? :[]=
52-
# Rails 4
53-
@scope[:jsonapi_resource] = @resource_type
54-
50+
# Rails 6+ and 8.1: always use the modern block style
51+
jsonapi_resource_scope(SingletonResource.new(@resource_type, api_only?, @scope[:shallow], options), @resource_type) do
5552
if block_given?
5653
yield
5754
else
5855
jsonapi_relationships
5956
end
60-
else
61-
# Rails 5
62-
jsonapi_resource_scope(SingletonResource.new(@resource_type, api_only?, @scope[:shallow], options), @resource_type) do
63-
if block_given?
64-
yield
65-
else
66-
jsonapi_relationships
67-
end
68-
end
6957
end
70-
# :nocov:
7158
end
7259
end
7360

0 commit comments

Comments
 (0)