:id
매개 변수에서 route globbing을 사용하려면 별도의 : show route를 만들려고합니다.레일 5 단일 리소스 경로 이름 이름 바꾸기
resource :test, except: [:show]
get 'test/*id', to: 'test#show', as: :test
문제가 나는 오류가 발생한다는 것입니다 : You may have defined two routes with the same name using the
: 나는 as: :test
을 제거하면 option, or you may be overriding a route already defined by a resource with the same naming.
로 작동이, 나는 쇼 노선이없는 자원 경로와 별도의 쇼 경로를 만들었습니다. rails routes
쇼 :
tests POST /tests(.:format)
new_test GET /tests/new(.:format)
edit_test GET /tests/:id/edit(.:format)
test PATCH /tests/:id(.:format) <-- WHY??
DELETE /tests/:id(.:format)
GET /tests/*id(.:format)
당신이 볼 수 있듯이, resources
는 :test
에 PATCH
경로를 이름. 해당 경로를 제거하면 test
등의 이름으로 DELETE
경로가 지정됩니다. resources
가 test
경로 이름을 구체적으로 사용하는 것을 어떻게 중지시킬 수 있습니까? resource
블록 위의 globbing 경로를 분명히 이동시킬 수는 없습니다. 왜냐하면 다른 모든 경로도 globed되기 때문입니다.
tests POST /tests(.:format)
new_test GET /tests/new(.:format)
edit_test GET /tests/:id/edit(.:format)
PATCH /tests/:id(.:format)
DELETE /tests/:id(.:format)
test GET /tests/*id(.:format)
다른 동사가있는 경로에서 동일한 경로 이름을 사용할 수 있다면 왜이 오류가 발생합니까? 'GET' 동사와 함께'test'라는 경로는 없습니다. –
경로 이름이 여러 동사에 동시에 사용된다는 것을 모르기 때문에이 대답을 올바로 수락합니다. 이 방법으로, 나는 이미 test라는 이름으로 내 경로를': : test'라고 부를 필요가 없습니다. –
@EikeCochu이 오류가 발생하면 무엇을하고 있습니까? 어떻게 사용하려고합니까? – piton4eg