How not to use the Rails action parameter in the controller

I am implementing a third-party API for Shipworks on the Rails server, and the Shipworks client application sends a parameter actionwith Shipworks specific semantics.

However, Rails routing logic overwrites this parameter as the name of the controller method.

Is there a special route that I could write to get the value of this action parameter without overwriting it as the name of my controller method?

+5
source share
2 answers

Today I fell into this trap and came up with this solution in the controller method. This is Rails 4.1:

if request.method == "POST"
  action = request.request_parameters['action']
else
  action = request.query_parameters['action']
end
+9
source

I get it. There is a method raw_postin AbstractRequest .

, , :

def raw_post_to_hash
  request.raw_post.split(/&/).inject({}) do |hash, setting|
    key, val = setting.split(/=/)
    hash[key.to_sym] = val
    hash
   end
end

raw_post_to_hash [: ] . , .

+3

All Articles