REST Questions

Hey, everybody.

I feel like I'm spinning my wheels trying to understand particular elements of REST. I've read many blogs and tutorials, watched the PeepCode REST screencast, and I've learned a lot, but it seems like the more advanced topics are kind of glossed over.

For instance, resources nested in multiple associations (or singularly) was demonstrated, but no code was built to prove the concept. I just saw how you got the fancy routes.

Here's what I mean. In routes.rb, you've got:

# ... map.resources :programs do |programs|   programs.resources :tags, :name_prefix => "programs_" end

map.resources :episodes do |episodes|   episodes.resources :tags, :name_prefix => "episodes_ end

map.resources :tags # ...

Glancing at this, I can't imagine how I could begin elegantly crafting TagsController.

Am I looking at this all wrong? Thanks in advance.

Derek

Hi

One approach which I have found works quite well is to use protocool's ResourceFu ( http://svn.protocool.com/public/plugins/resource_fu/ ), which lets you have one common 'tags' controller, and then a ProgramTags controller which delegates most of its functionality to the TagController, similarly for the EpisodeTags controller.

The documentation is a little lacking, but there is a working example of how to use ResourceFu in the caboo.se sample app, available at http://sample.caboo.se/

Regards, Jonathan