@@ -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
0 commit comments