graphiti icon indicating copy to clipboard operation
graphiti copied to clipboard

Makes singleton resources finding with an id work

Open doublevoid opened this issue 2 years ago • 0 comments

Creating a resource, setting a primary endpoint, and then using ResourceName.find({id: id}) doesn't work if the controller is set up as a show action. You get ResourceName cannot be called directly from endpoint /api/v1/resource#show!

This is why. A workaround is to either go with self.validate_endpoints = false or change the action to be an index action, which bypasses the stripping of a would-be id.

This PR changes the behavior to only strip the id from path if the id is actually in path!

doublevoid avatar Feb 10 '23 19:02 doublevoid