Topic: REST and habtm

I'm just trying to work out how something will work with REST.

My Task and Document Model have a habtm relationship.  When you add a new Document you must add it to a Task.  However I want to give the option of adding it to other tasks later.  I don't want to do this through the edit/update page - I want it to be a distinctly seperate action (kind of like a tagging idea).  I'm actually going to be doing something similar to this with other models too.

How can I do this RESTfully?  Do I just have to break out of REST and create a new action in my Document controller, or should I create a seperate controller for document_tasks?  Or is there some way I haven't thought of yet?

Re: REST and habtm

I recommend making an explicit join model in between Task and Document - like Documented or Tasking or something like that.  Then make it it's own resource with a full controller.

Rails is moving very quickly away from habtm I'm noticing.

Re: REST and habtm

Yep, explicit join model is the way to go.  Almost all of those questions just fall into place when you embrace those join tables and turn them into first-class citizens in your domain model.   The whole thing didn't really click with me at first.  I think I was brain-damaged too much time spent with ORM solutions that did everything they could to hide join tables from you.  But then I watched DHH's RailsConf keynote and I understood. If you haven't seen it yet, I really recommend it highly.

http://www.scribemedia.org/2006/07/09/dhh/