get and post on the same controller method

What happens if you have get and post on the same method on a controller?

Would it always be get first then if a user clicks on the submit button becomes post? How do you set certain conditions that only must happen if a user hits the submit button sending a post request?

If your routes file maps get and post for a path to a controller action then it’s up to that action do decide whether to handle things differently (e.g. by checking request.method (or the helpers etc))


@Kareem Gan

I do not think you realise that the two questions you have asked are
different. The first one is asking what would happen if you have
defined routes (in routes.rb) that direct both get and post to the
same action in the controller (which Frederick has addressed), the
second is asking whether get or post will be sent with request when
you click a button or link in a web page or form. The answer to the
second question is that it is entirely up to the html in the page
which it will send. Links and buttons can be coded to use either by
using additional options in the html, but the default is that a form
submit button will always use post and a normal link will use get.