Rails options from GET / POST

I am new to Rails and am writing a registration form. I used form_tag to pass the user view to the account controller. Now I don’t want the user to be able to enter their login information through a GET request, so how can I verify that a specific parameter is either a GET parameter or a POST?

Thanks in advance

+5
source share
3 answers

In Rails, you do not have specific POST or GET parameters. You have a POST or GET request. You can check this as on the controller:

request.post?

or you can check other HTTP verbs: GET, PUT and DELETE:

request.get?
request.put?
request.delete?

: http://railsapi.com/doc/rails-v2.3.8/classes/ActionController/Request.html

+17

HTTP-, :

request.request_method 
+2

, POST URL-, , , . , :

if request.GET.include? "param_name"
  # do something
end

request.POST (query_parameters GET request_parameters POST) ActionDispatch::Request:

http://api.rubyonrails.org/classes/ActionDispatch/Request.html#method-i-GET

0

All Articles