From 120f06e1f2b8e4269ff6b92006c1d30ace004eb5 Mon Sep 17 00:00:00 2001 From: David Stosik Date: Tue, 29 Mar 2016 18:29:28 +0900 Subject: [PATCH] Allow custom constraints on `jsonapi_resources` routes. --- lib/jsonapi/routing_ext.rb | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/jsonapi/routing_ext.rb b/lib/jsonapi/routing_ext.rb index b8a88b540..537e120ae 100644 --- a/lib/jsonapi/routing_ext.rb +++ b/lib/jsonapi/routing_ext.rb @@ -69,7 +69,8 @@ def jsonapi_resources(*resources, &_block) options[:path] = format_route(@resource_type) if res.resource_key_type == :uuid - 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}/} + options[:constraints] ||= {} + 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}/ end if options[:except]