Rails routes or how to get rid of match?

0 like 0 dislike
6 views
Hello!
There are resources :questions it creates action new which runs a GET request, how to change in POST?

So far I have this:
match '/questions/new', to: 'questions#new', as: 'new_question', via: :post


Link
Avoid using the #match to determine the routes
by | 6 views

2 Answers

0 like 0 dislike
post '/questions/new', to: 'questions#new', as: 'new_question'

?
by
0 like 0 dislike
resourcescreates a set of specific routes. This is described in the documentation.

If you want to add a custom route and post :new - it is just the same like this, it is necessary to register it additionally by

post '/questions/new', to: 'questions#new', as: 'new_question'
by
110,608 questions
257,186 answers
0 comments
33,949 users