Projects have many tasks and a task has a custom RESTful action called 'approve'.
项目有许多任务,任务有一个名为“approve”的自定义RESTful操作。
I'm expecting the helper to look something like this approve_project_task_url
我希望助手看起来像这样approve_project_task_url
This isn't working for me:
这对我不起作用:
map.resources :projects,
:has_many => :tasks,
:member => { :approve => :post }
2 个解决方案
#1
10
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 do |project|
project.resources :tasks, :member => {:approve => :post}
end
That will give you your required approve_project_task_url(@project, @task)
routes/helpers.
这将为您提供所需的approve_project_task_url(@project, @task)路由/helper。
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 :)
我想你可能已经知道这个方法了吧?如果是的话,如果你不喜欢的话,我希望我能从你的其他回复中学到一些东西。
#2
1
**This is syntax correction to above solution**
map.resources :projects do |project|
project.resources :tasks, :member => {:approve => :post}
end
#1
10
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 do |project|
project.resources :tasks, :member => {:approve => :post}
end
That will give you your required approve_project_task_url(@project, @task)
routes/helpers.
这将为您提供所需的approve_project_task_url(@project, @task)路由/helper。
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 :)
我想你可能已经知道这个方法了吧?如果是的话,如果你不喜欢的话,我希望我能从你的其他回复中学到一些东西。
#2
1
**This is syntax correction to above solution**
map.resources :projects do |project|
project.resources :tasks, :member => {:approve => :post}
end