I've a design question about a RESTful Weblog application. I use the
db layout: http://erdbeere.net/media/db_layout.png . There is a
controller for each model. Now I want to have something like "popular
posts", "recent posts", "post with the most comments", "current
users", "most active users", ...
If I understand Rest correctly, i should have a ressource for each
statistic, but should I really create a controller for each of them?
You don't need a controller for each resource in this case - as long
as you can identify it by URL, then it's a resource. So, if you want,
you can provide named urls that point to each resource:
However, it means that your controller would need a custom 'popular'
action --- which is not the end of the world, but I tend to look for
alternatives before resorting to custom actions. So another approach
would be to use urls like:
/posts?subset=popular
which is still RESTful, and are easily generated with:
Thank you, Jeff. It is really helpful for me. I think I have to learn
a lot to use REST and Rails, but a workshop in TX is much to far away
from europe