Ruby: How to turn a hash into HTTP parameters?

后端 未结 14 1607
故里飘歌
故里飘歌 2020-12-07 06:46

That is pretty easy with a plain hash like

{:a => \"a\", :b => \"b\"} 

which would translate into

\"a=a&b=b\"
<         


        
14条回答
  •  悲&欢浪女
    2020-12-07 07:53

    If you are in the context of a Faraday request, you can also just pass the params hash as the second argument and faraday takes care of making proper param URL part out of it:

    faraday_instance.get(url, params_hsh)
    

提交回复
热议问题