views:

35

answers:

1

Hi,

I'm fairly new to Rails and am writing a login form. I have used form_tag to pass through the user's submission to the account controller. Now, I don't want the user to be able to enter their login details through a GET request, so how can I check that a certain param is either a GET or POST parameter?

Thanks in advance

A: 

In Rails you don't have specific POST or GET parameters. You do have a POST or GET request. You can check it like this in your controller:

request.post?

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

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

For more info, check this piece of the documentation: http://railsapi.com/doc/rails-v2.3.8/classes/ActionController/Request.html

Ariejan
In Rails parameters are always accessible through `params[:name]` no matter if they were POSTed or GETed.
Ariejan
ok I suppose that will have to do, thanks for the info
alex