On Thursday, February 19, 2015 at 7:20:31 PM UTC-5, jbrown wrote:
The docs give a different impression.
Docs:
-- One line of code for enabling resources, set of resulting URL mappings
Result: All mappings work great out of the box.
-- Additional line of code for enabling nested resources, set of resulting URL mappings
Result: Almost all mappings fail counterintuitively out of the box.
GET "/owners/2/pets" returns *all* pets, not just owner[id=2]'s pets
PUT "/owners/2/pets" doesn't work unless you repeat yourself
PUT "/owners/2/pets" {owner: {id=3}, name="max"} "works"
GET "/owners/7/pets/3" works even if owner 7 doesn't exist.
You're right, though. Even in the Graeme's video, he demonstrates the custom code needed for child reads, although his example doesn't handle updates and deletes.
So yup, not a bug. As much as I'd love nested resources to work as cleanly as the docs indicate, the remedy here is to make it clear that nested resources requires careful extension of RestfulController.
You'll find documenting the appropriate extensions to be a challenge, though. I had to override queryForResource, listAllResources, createResource, and delete.
-Adam