Hi,
I’m trying to make the following routes, but also accept POST for the /quiz/files/new path.
namespace :quiz do
resources :files
end
# Prefix Verb URI Pattern Controller#Action
# quiz_files GET /quiz/files(.:format) quiz/files#index
# POST /quiz/files(.:format) quiz/files#create
# new_quiz_file GET /quiz/files/new(.:format) quiz/files#new
# edit_quiz_file GET /quiz/files/:id/edit(.:format) quiz/files#edit
# quiz_file GET /quiz/files/:id(.:format) quiz/files#show
# PATCH /quiz/files/:id(.:format) quiz/files#update
# PUT /quiz/files/:id(.:format) quiz/files#update
# DELETE /quiz/files/:id(.:format) quiz/files#destroy
I was able to make it with the following:
namespace :quiz do
resources :files, except: :new
end
match "quiz/files/new", via: [:get, :post], as: :new_quiz_file
# Prefix Verb URI Pattern Controller#Action
# quiz_files GET /quiz/files(.:format) quiz/files#index
# POST /quiz/files(.:format) quiz/files#create
# edit_quiz_file GET /quiz/files/:id/edit(.:format) quiz/files#edit
# quiz_file GET /quiz/files/:id(.:format) quiz/files#show
# PATCH /quiz/files/:id(.:format) quiz/files#update
# PUT /quiz/files/:id(.:format) quiz/files#update
# DELETE /quiz/files/:id(.:format) quiz/files#destroy
# new_quiz_file GET|POST /quiz/files/new(.:format) quiz/files#new
Is there a better way to achieve this?