Parse a string as if it were a querystring in Ruby on Rails

前端 未结 5 407
终归单人心
终归单人心 2020-11-28 23:12

I have a string like this:

\"foo=bar&bar=foo&hello=hi\"

Does Ruby on Rails provide methods to parse this as if it is a querystring,

5条回答
  •  谎友^
    谎友^ (楼主)
    2020-11-28 23:46

    If you talking about the Urls that is being used to get data about the parameters them

    > request.url
    => "http://localhost:3000/restaurants/lokesh-dhaba?data=some&more=thisIsMore"
    

    Then to get the query parameters. use

    > request.query_parameters
    => {"data"=>"some", "more"=>"thisIsMore"}
    

提交回复
热议问题