Is there a Ruby library/gem that will generate a URL based on a set of parameters?

Yes, in Ruby’s standard library you’ll find a whole module of classes for working with URI’s. There’s one for HTTP. You can call #build with some arguments, much like you showed.

http://www.ruby-doc.org/stdlib/libdoc/uri/rdoc/classes/URI/HTTP.html#M009497

For the query string itself, just use Rails’ Hash addition #to_query. i.e.

uri = URI::HTTP.build(:host => "www.google.com", :query => { :q => "test" }.to_query)

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)