views:

584

answers:

2

Projects have many tasks and a task has a custom RESTful action called 'approve'.

I'm expecting the helper to look something like this approve_project_task_url

This isn't working for me:

map.resources :projects,
              :has_many => :tasks,
                           :member => { :approve => :post }
+9  A: 

I once had the same problem but I never searched long and hard for a fix. Instead I just opted for the older style which since then I've always used:

map.resources :projects as |project|
  project.resources :tasks, :member => {:approve => :post}
end

That will give you your required approve_project_task_url(@project, @task) routes/helpers.

I guess you may already know this approach? If so and you don't like it hopefully I'll learn something from your other responses :)

tsdbrown
You can also use "rake routes" to see what routes have been created.
Lee Irving
That is the fix. :has_many is just a shortcut for when it's not complicated.
Ian Terrell
@Ian: that's good for me to know too, cheers.
tsdbrown
+1  A: 
 **This is syntax correction to above solution**

map.resources :projects do |project|
  project.resources :tasks, :member => {:approve => :post}
end
Subba Rao