Switching between representations of one model


#1

I’m trying to figure out the most idiomatic way to tab between multiple representations of the same model (or more specifically, an array of models).

I know that one option is to use actions on the controller or route that filter the array. However, I think it’s also desirable to have a route for each representation.

Here’s a specific example: I have a Board route and model, and each Board has many Stories. Those Stories can be filtered by ‘all’, ‘new’, and ‘top.’ One solution is to have one route /boards/:board_id, and to have each tab trigger a controller action that does the filtering. In this case, the Board route needs the stories/index controller, and is responsible for setting up the stories/index controller and rendering the stories/index template into an outlet in the board.index template.

Another solution is to have routes /boards/:board_id/top, /boards/:board_id/new, and /boards/:board_id/all. In this case, what’s the best way to manage relationships between the controllers? Especially considering that, in each case, the Stories are just a filtered representation of the board.stories relationship?

Note also that I’m purposely avoiding embedding a Stories resource in the Board resource (resulting in routes like /board/:board_id/stories/*).