Sha256: 8ee52ce09b837f266bbc07a3e32d4196563d19987882731b84cafc50369ae06d
Contents?: true
Size: 1.9 KB
Versions: 11
Compression:
Stored size: 1.9 KB
Contents
# This exists because JSON API Resources won't let you route to 'new' or 'edit' # and clobbers the value of the :except param to jsonapi_resources # In order to support new and edit forms we have to patch these routing helpers # for now module ActionDispatch module Routing class Mapper Resources.class_eval do def jsonapi_resource(*resources, &_block) @resource_type = resources.first res = JSONAPI::Resource.resource_for(resource_type_with_module_prefix(@resource_type)) options = resources.extract_options!.dup options[:controller] ||= @resource_type options.merge!(res.routing_resource_options) options[:path] = format_route(@resource_type) resource @resource_type, options do @scope[:jsonapi_resource] = @resource_type if block_given? yield else jsonapi_relationships end end end def jsonapi_resources(*resources, &_block) @resource_type = resources.first res = JSONAPI::Resource.resource_for(resource_type_with_module_prefix(@resource_type)) options = resources.extract_options!.dup options[:controller] ||= @resource_type options.merge!(res.routing_resource_options) options[:param] = :id 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}(,[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 resources @resource_type, options do @scope[:jsonapi_resource] = @resource_type if block_given? yield else jsonapi_relationships end end end end end end end
Version data entries
11 entries across 11 versions & 1 rubygems