Results 1 to 8 of 8
Jun 4, 2007, 06:30 #1
- Join Date
- May 2007
- 0 Post(s)
- 0 Thread(s)
Being RESTful and avoiding redundancy question
I've been reading about building RESTful applications and it sounds like a good approach that I want to use (great overview: http://softiesonrails.com/2007/3/28/...ding-resources )
Question: how do I avoid redundancy if I have several controllers that do similar but slightly distinct things?
For example, let's say I'm building a forum site with 2 categories: music and cars. People can click on the "music" tab to see discussions and add comments about music; they can click on the "cars" tab for discussions about cars.
I create a model called Discussion and two controllers -- carDiscussion_controller and musicDiscussion_controller. Each controller has the standard 7 RESTful methods (index, show, new, edit, update, create, destroy). Thus, the index method of musicDiscussion could be customized to list only discussions related to music.
This seems good and maybe it is, but I'm afraid there will some redundancy. For example, the destroy method will always do the same thing -- destroy a discussion. Is this a problem? Is there a better way to do this?