File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,7 +13,28 @@ class Error
1313 def self . status_code_for ( status_symbol )
1414 return nil if status_symbol . nil?
1515
16- # Try the symbol directly first
16+ # Use Rack::Utils.status_code if available (Rack 3.0+)
17+ if Rack ::Utils . respond_to? ( :status_code )
18+ begin
19+ # status_code returns integer, convert to string
20+ code = Rack ::Utils . status_code ( status_symbol )
21+ return code &.to_s
22+ rescue ArgumentError
23+ # If the symbol is not recognized, try deprecated symbols
24+ if DEPRECATED_STATUS_SYMBOLS . key? ( status_symbol )
25+ begin
26+ code = Rack ::Utils . status_code ( DEPRECATED_STATUS_SYMBOLS [ status_symbol ] )
27+ return code &.to_s
28+ rescue ArgumentError
29+ # Symbol not found even after trying deprecated mapping
30+ return nil
31+ end
32+ end
33+ return nil
34+ end
35+ end
36+
37+ # Fallback to SYMBOL_TO_STATUS_CODE for Rack 2.x
1738 code = Rack ::Utils ::SYMBOL_TO_STATUS_CODE [ status_symbol ]
1839
1940 # If not found and it's a deprecated symbol, try the new symbol
Original file line number Diff line number Diff line change @@ -46,7 +46,7 @@ def jsonapi_resource(*resources, &_block)
4646 options [ :except ] << :destroy unless options [ :except ] . include? ( :destroy ) || options [ :except ] . include? ( 'destroy' )
4747 end
4848
49- resource @resource_type , options do
49+ resource @resource_type , ** options do
5050 # :nocov:
5151 if @scope . respond_to? ( :[]= )
5252 # Rails 4
@@ -133,7 +133,7 @@ def jsonapi_resources(*resources, &_block)
133133 options [ :except ] << :destroy unless options [ :except ] . include? ( :destroy ) || options [ :except ] . include? ( 'destroy' )
134134 end
135135
136- resources @resource_type , options do
136+ resources @resource_type , ** options do
137137 # :nocov:
138138 if @scope . respond_to? ( :[]= )
139139 # Rails 4
You can’t perform that action at this time.
0 commit comments