I have a MVC web application (Ruby, Rack, Apache) and I want it to be restful.
I have a dispatcher that will get incoming URI and call the appropriate controller.
In my mind, a controller is there to handle every actions linked to a single model, I am wrong ?
The thing I am not sure about is a case like the following:
If a user has several items, how can I get a specific item using the URI /user/user_id/item/item_id
I mean, is this somethings that should be handled within the UserController or do I need to create another “cross classes” controller such as UserItemController that should take care of this king of stuff ?
I hope I’m clear 🙂
Thanks a lot,
Luc
The organization of your methods in controllers or models have little to do with wether your app is going to be restful or not. Ideally try to map 1 controller to 1 model, but you could have a controller dedicated to an action (
loginfor instance).What you want to look at is the routes.rb file. This is where you will map ressources and so on.
I recommend reading the excellent article of Ryan Tomayko about REST