action snippets

HTTP parameter named "action" is reserved in Rails

Tagged parameter, rails, http, action  Languages ruby

The "action" HTTP parameter is reserved in Rails, so you don't see it in the logs or in the params hash.

So how do you read the "action" parameter?

For GET:

Rack::Utils.parse_nested_query(env['QUERY_STRING'])['action']

For POST:

post_body = request.body.read
request.body.rewind if request.body.respond_to?(:rewind)
post_params = CGI.parse(post_body)
post_params['action'].try(:first)