Reputation: 3264
The rails redirected_to is get or post
and the link_to is i think will be a GET request.(correct me if am wrong)
And can u please mention something about request.post?
Upvotes: 1
Views: 982
Reputation: 1500
In Rails, redirect_to (did you mean that with *redirected_to* ?) helper outputs the HTTP header which is needed to instruct browser to move to another page, so the browser will do a GET request to the new address.
In HTTP spec there's no way to perform a redirect via the POST verb.
Upvotes: 1
Reputation: 1200
redirect_to tells the browser to issue a GET-request to the given URL. So to answer your question, redirect_to (indirectly) creates a GET-request, like link_to.
Upvotes: 1
Reputation: 5723
Redirects are reponses sent by the SERVER. GETs/POSTs are sent by the BROWSER. A redirect can be a (server!) response to either a GET or a POST.
request.post? in Rails controllers is "true" if the request was made as a POST, and "false" in all other cases.
link_to creates link HTMNL links, so naturally they can only cause GET requests - only via XHR or through a can you cause a browser to POST requests.
Upvotes: 1