0

I want to use a conditional to run a statement based on the type of request, but there is no way I can reproduce the error in production to see what the request is, but I was thinking of doing it this way:

def save_path
    if request.method == 'GET'
        # don't save the timeout path or else the user has no obvious way to log in
        session[:desired_path] = request.url unless request.url =~ /#{timeout_path}$/
    end
end

So, basically I want to say if the request's method is a GET request then this line should run but don't know if my conditional is setup correctly or not. Any assistance on this will be greatly appreciated.

Eyeslandic
  • 14,553
  • 13
  • 41
  • 54
Pouya
  • 65
  • 6
  • Does this answer your question? [Rails parameters from GET/POST](https://stackoverflow.com/questions/4023496/rails-parameters-from-get-post) – Eyeslandic Oct 14 '21 at 18:57

1 Answers1

2

You can check using a built in method:

request.get?

This answer to a similar question may be helpful for further info:

https://stackoverflow.com/a/4023538/3435610

Sara Fuerst
  • 5,688
  • 8
  • 43
  • 86