HTTPS clone URL
Subversion checkout URL
Implementing REST services in Ruby on Rails usually means to follow the steps:
- create a set of models which should be exposed resourcefully
- for all models write a controller, maybe with help of plugins like make_resourceful, or craft by hand
- put business logic, access control, paging into the controllers actions
- remove and add actions according to the business logic
- create the usual HTTP responses for the actions
- set up routing for the controllers
One ends up with a lot of controllers that are similar, but not quite the same. They all mix the REST logic - which is a technical aspect - with business logic. To my experience controller code, which is quite neat at the start, gets overwhelmed by business logic and becomes hard to maintain, because it appears to be easy and quick to do that, instead of refactoring some model code.
Toast is an experiment to separate the technical aspects of the controller (receive a request, decode it, do something with a model, create a response) from the business logic to that extent that coding a specialized controller becomes unnecessary. A widely recommended strategy is to code skinny controllers. For REST they become so skinny and similar that it makes sense to use a generic controller. Whatever there is different can be configured in the model class that is to be served by it. In other words: The model defines it's own controller.