If you are adding member methods like "add_content" and "delete_content" then you have left REST behind.
I understand that a Service is a resource that has many Sections. The content already exists, but you want to add it to another section. HABTM associations are usually processed by a list of checkboxes named "section[contents][]". So in your edit form for the Section, you offer the checkboxes. In the update action of the Section, the checkboxes get processed automatically when you update attributes. On Aug 25, 9:44 am, Diego Suarez <[email protected]> wrote: > Hello, > > Sorry if this has been answered in old posts, I couldn't find anything. > This has been killing me all the morning :-( I'm a bit new to REST, and > I'm trying to model my app routes 'restfully', but I get lost on many > things. > I've been searching how to do this with resources: > I have a Service model that has many Sections, and Sections have and > belong to many Contents. But the Contents don't have to be in a Section > (it's optional). > I want to be able to add a content to a section, and remove a content > from a section. With nested resources I could do something like this: > ----- > map.resources :services, :shallow=>"true" do |service| > service.resources :sections do |section| > section.resources :contents > end > end > map.resources :contents > ---- > But it isn't what I'm searching. I want to do something that allows me > to have a route like "POST /services/32/sections/14/add_content/5", > because "POST /services/32/sections/14/contents/" would create a content > in the section 14, but I don't want a new one. I only want to add an > existing content to a existing section (or delete it). I saw somewhere a > forum post proposing something like (adapted to this case): > --- > map.resources :services, :shallow=>"true" do |service| > service.resources :sections, :member=>{:add_content=>:post, > :remove_content=>:delete} do |section| > end > end > map.resources :contents > --- > But the "member" functions only allow me to operate on the section, and > I cant specify the content id (only by giving a ?content_id=5 after the > URL). Is there anything I can do without falling back to map.connect? > > Best regards and thanks in advance, > > Diego. > -- > Posted viahttp://www.ruby-forum.com/. -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

