From 3fcf0df4eb433f0838b784ba94d2b34c165ab181 Mon Sep 17 00:00:00 2001 From: Hidde-Jan Jongsma Date: Wed, 22 Feb 2017 10:07:01 +0100 Subject: [PATCH 1/2] Use plural of resource type for controller Currently, doing `jsonapi_resource :current_user` will use the `CurrentUserController`, however, any relationships on the `current_user` resource will instead look for the `CurrentUsersController`. By default, rails uses the plural name controller for any singular resource. Keeping this the same for JA:R seems like a good idea. --- lib/jsonapi/routing_ext.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jsonapi/routing_ext.rb b/lib/jsonapi/routing_ext.rb index 045090cc4..3738280f9 100644 --- a/lib/jsonapi/routing_ext.rb +++ b/lib/jsonapi/routing_ext.rb @@ -21,7 +21,7 @@ def jsonapi_resource(*resources, &_block) res = JSONAPI::Resource.resource_klass_for(resource_type_with_module_prefix(@resource_type)) options = resources.extract_options!.dup - options[:controller] ||= @resource_type + options[:controller] ||= @resource_type.pluralize options.merge!(res.routing_resource_options) options[:path] = format_route(@resource_type) From f2e7be614e558a82be4d23aeca32ed0a6282664b Mon Sep 17 00:00:00 2001 From: Hidde-Jan Jongsma Date: Wed, 22 Feb 2017 11:05:36 +0100 Subject: [PATCH 2/2] Pass context to verify_key of parent resource in show relationship --- lib/jsonapi/request_parser.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/jsonapi/request_parser.rb b/lib/jsonapi/request_parser.rb index 14d2ca487..8d75ed6c2 100644 --- a/lib/jsonapi/request_parser.rb +++ b/lib/jsonapi/request_parser.rb @@ -152,7 +152,7 @@ def setup_show_relationship_action(params, resource_klass) resource_klass, context: @context, relationship_type: relationship_type, - parent_key: resource_klass.verify_key(parent_key) + parent_key: resource_klass.verify_key(parent_key, @context) ) end