How to not use Rails action parameter in controller

前端 未结 2 845
清歌不尽
清歌不尽 2020-12-31 23:37

I am implementing a third party API for Shipworks in a Rails server and the Shipworks client app is posting an action param with Shipworks specific semantics.

2条回答
  •  别那么骄傲
    2021-01-01 00:02

    I figured it out. There is a raw_post method in AbstractRequest.

    So you can do this to parse the raw post params:

    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
    

    and then just call raw_post_to_hash[:action] to access the original action param or any other param. There is probably an easier way.

提交回复
热议问题