resources :patients do
collection do
get 'new_import'
post 'import'
end
我如何拥有以下网址?
/patients/import (GET) -->ACTION: new_import
/patients/import (POST) --> ACTION: import
现在的URL是:
/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
答案 0 :(得分:2)
resources :patients do collection do get 'import' => :new_import post 'import' => :import end end
答案 1 :(得分:1)
就像你写在上面一样:
resources :patients do
collection do
get 'new_import'
post 'import'
end
end
尝试访问此网址时是否有任何错误?