Skip to content

Commit d4880fe

Browse files
committed
Merge pull request #662 from kenzai/allow-custom-constraints-on-routes
Allow custom constraints on UUID resource routes generated by `jsonapi_resources`
2 parents e9bcc4e + 120f06e commit d4880fe

1 file changed

Lines changed: 2 additions & 1 deletion

File tree

lib/jsonapi/routing_ext.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,8 @@ def jsonapi_resources(*resources, &_block)
8181
options[:path] = format_route(@resource_type)
8282

8383
if res.resource_key_type == :uuid
84-
options[:constraints] = {id: /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/}
84+
options[:constraints] ||= {}
85+
options[:constraints][:id] ||= /[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}/
8586
end
8687

8788
if options[:except]

0 commit comments

Comments
 (0)