Resource nested in multiple other resources

I was wondering how one would approach writing a controller for a
resource that is nested in 2 or more other resources, where the view
and behavior change (albeit slightly) depending on who the parent
resource is.

For example:

Is there a DRY way to handle this without using a bunch of case

Would it make much difference if there was a need to access the nested
resource directly as well:

One way that I've thought about but haven't fully fleshed out is using
defining a class BooksController and then define child classes like
AuthorBooksContoller < BooksController and using inheritance to handle
the common methods. How would this work out in the views? Am I
approaching this all wrong?



You could have a filter in the books_controller to pick out any
author_id, publisher_id, etc. and scope the Book.find(...) according
to these params. That should be simple and DRY.

Hope this helps.