嵌套资源路由
问题描述:
resources :patients do
collection do
get 'new_import'
post 'import'
end
如何获取以下网址?嵌套资源路由
/patients/import (GET) -->ACTION: new_import
/patients/import (POST) --> ACTION: import
现在的网址是:
/patients/new_import (GET) -->ACTION: new_import
/patients/import (POST) --> ACTION: import
我一定能做到这一点而不做:
match 'patients/import' => 'patients#new_import', :via => :get
match 'patients/import' => 'patients#import', :via => :post
答
resources :patients do collection do get 'import' => :new_import post 'import' => :import end end
答
就像你已经写在上面:
resources :patients do
collection do
get 'new_import'
post 'import'
end
end
您在尝试访问此网址时是否有任何错误?
+0
大声笑,有史以来最容易的赏金。 +1 – 2011-03-09 14:25:33
+0
我不认为我提出的问题足够清楚。我想为这两个操作使用相同的患者/导入网址。一个通过获取和一个通过一个职位。我会更新这个问题,以便更清楚。 – 2011-03-09 14:58:45
谢谢你的工作!我会在22小时内奖励你的赏金。我想知道为什么这没有记录! – 2011-03-09 16:05:03