Just wondering -- how do you know when to add map.resources for a particular model? All of them? The ones you want to be accessible by a public API?
Thanks.
Just wondering -- how do you know when to add map.resources for a particular model? All of them? The ones you want to be accessible by a public API?
Thanks.
Yes, you are deliberately exposing something as a kind of service, decide whetehr that's want you want to do. Exposing a service implies a certain commitment to your users, general advice keep the number of exposed services under control, they incur onging support debt.
First of all we do not add map.resources for models. We add them for our controllers.
The map.resources and map.resource generate RESTful urls which do not address a model and its corresponding actions; it addresses only the resource itself. A resource is a combination of dedicated controller and a model.
Usually if you are going to make a complete RESTful app, you add map.respources for all of your controllers. After doing this, you can define all your CRUD(index, new, create, edit and update) actions in the corresponding controller which access a particular resource. The actions which can be carried out on a particular resource depend upon the policies defined by your application. If you have some resource which you do not want the users(via your application front end or via some API) of your application see(or something like that), you simply don't define a show action in the corresponding controller. Similarly other actions.
You should have a look at this small tutorial about REST and Rails. The lines above in the quote are shamelessly copied from the same document.