On 2 December 2014 at 18:16, Kareem Gan <[email protected]> wrote: > 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?
@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. Colin -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/CAL%3D0gLs-j%3DmkkVJCnRFbEiphro3zTzuGFt1_6Fj2kOPZY1_n8w%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

