Closed kcalmes closed 8 years ago
I'm not a maintainer, but as per this comment:
Nested resources are not yet a supported feature.
I think the fact that you're "allowed" to create such route structures anyway is an accidental side effect of using blocks to customize which relationship/related-resource routes are generated.
As a point of advice, it usually makes sense to have routes be as shallow as possible (so e.g. /farms/1/animals
is valid, but individual animals are accessed at /animals/5
). While the JSONAPI spec doesn't technically prescribe any route structure, this is the structure used in their examples, and is also the only structure supported out of the box by many client libraries. JSONAPI::Resources itself also assumes your routes are arranged this way when it generates links (i.e. the generated link for an animal will be /animals/5
even if you have no such route).
When I have the following setup
routes.rb
resources/namespace/animal_resource.rb
resources/namespace/cat_resource.rb
When making a request to
/namespace/animal-resources/5
the type iscat
as it should be according to https://github.com/cerebris/jsonapi-resources#immutable-heterogeneous-collectionshowever, when making a request to
/namespace/farms/1/animal-resources/5
the type isanimal
, but it should becat
This seems to be a bug, any thoughts?