How define routes for POST/PUT/GET methods when using ‘form_tag’ form? should I define in model a method POST or PUT? Or if I have e.g. browsing method then I should do with route something like this: (warning! pseudo-code below)
match 'browsing/mymethod' => 'browsing#post'
please help! 🙁
If your form does not alter the database state (does not create, update or delete records) nor does it contain sensitive data (like login credentials), for example if it’s a search form and you use it to filter results, use the GET HTTP verb:
get 'browsing/mymethod' => 'browsing#filter'If it’s a form that creates data in the database or it creates some resource (starts an authentication session for example), use the POST HTTP verb:
post 'browsing/mymethod' => 'browsing#create'NOTE: We are talking about the action where the form submits, not the possible auxiliary action that displays the form!
If it’s a form that updates data in the database or it changes some resource, use the PUT HTTP verb:
put 'browsing/mymethod' => 'browsing#update'Finally, if it’s a form that when submitted, deletes data, (usually just a button, no other fields in the form), use DELETE HTTP verb:
delete 'browsing/mymethod' => 'browsing#destroy'