Topic: Another Question Regarding REST
This may be more about my application design than REST.
I'm looking to refactor an existing application to take advantage of REST. Right now, I'm using one controller to handle the CRUD operations for three sibling STI models (journal, book and database all inherit from item). So in my routes.rb I've got something like:
map.journal_list 'journals/list/:letter', :controller => "items", :action => 'list', :type => 'journal'
map.database_list 'databases/list/:letter', :controller => "items", :action => 'list', :type => 'database'
map.book_list 'books/list/:letter', :controller => "items", :action => 'list', :type => 'book'
The single controller uses the :type param to programmatically decide which Model to use. It might be the entirely wrong thing to do (please enlighten me). But, it seemed like good DRY practice and appears to work well in my case.
In order to convert that to REST, I [i]think[i] I could do something like:
map.resources :journals, :controller => 'links', :name_prefix => "journal_"
But that doesn't seem to work and in any case doesn't provide a means for passing parameters from the route definition (ala :type => ...).
Am I way out in left field here? It looks like the only way to use REST is to refactor my single controller to separate controllers for each of the models. Any thoughts? Thanks.