Open wpliao1989 opened 4 years ago
Just opened a PR which addresses this issue. Multiple belongs_to :resource, shallow_path: true
will now be possible.
Thanks! Did you look into _prefix_path
method on line 311 as well? Its implementation is very similar to _set_prefix_path
.
Just checked again. Compacted the array in the path getter as well!
Will add tests early tomorrow. At least the current suite doesn't break locally. Is there any difference on travis? On travis the runner fails.
Steps to reproduce:
What's wrong:
This part of code: https://github.com/JsonApiClient/json_api_client/blob/db890adf3d7175e91829d359336ab7c98ed90a34/lib/json_api_client/resource.rb#L324
a.set_prefix_path(attrs, route_formatter)
can returnnil
if usingshallow_path
. If there are 2 or morebelongs_to
association in the resource,paths.join("/")
would return extra slashes ([nil, nil].join('/') => '/'
).Possible fix:
Remove
nil
s:Also, I'm not sure what
_prefix_path
is meant to do so maybe we need to fix that method too.