Forums
New posts
Search forums
Members
Current visitors
Log in
Register
What's new
Search
Search
Search titles only
By:
New posts
Search forums
Menu
Log in
Register
Install the app
Install
Forums
Archive
Archive
Ruby
how to do the equivalent of PHP's "$_GET" in Ruby?
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
[QUOTE="Jano Svitok, post: 4606428"] 1. Please bottom post (i.e. write your reply under the previous one). It's easier to read. 2. For rails related questions, [URL]http://groups.google.com/group/rubyonrails-talk[/URL] is more suitable - you'll get better/more specific answers there. Nonetheless, this is a nice ruby question, so here you go: params.each do | key, value| url << key << "=" << value << "&" end Notes: 1. it's either do...end or {...}, 2. each for Hash takes two-parameter block see [URL]http://ruby-doc.org/core/[/URL], class Hash. you'll find there a lot of nice and useful stuff. For this particular case, Enumerable#map and Array#join are handy: url = params.map {|key, value| "#{key}=#{value}" }.join('&') This way you won't have the trailing &. J. [/QUOTE]
Verification
Post reply
Forums
Archive
Archive
Ruby
how to do the equivalent of PHP's "$_GET" in Ruby?
Top