Is there is a way to get the query string in a passed URL string in Rails?
I want to pass a URL string:
http://www.foo.com?id=4&empid=6
How can I get id and empid?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
If you have a URL in a string then use URI and CGI to pull it apart:
Please use the standard libraries for this stuff, don’t try and do it yourself with regular expressions.
Also see Quv’s comment about
Rack::Utils.parse_querybelow.References:
CGI.parseURI.parseUpdate: These days I’d probably be using
Addressable::Uriinstead ofURIfrom the standard library: