I Rails, to convert a Hash object into a query string or parameter string for use in a url:
opts = {:a => 1, :b => 2}
params = ActionController::Routing::Route.new.build_query_string(opts)
Params => "?a=1&b=2"
Tuesday, March 02, 2010
Subscribe to:
Post Comments (Atom)
1 comment:
or just use { :a => 'b' }.to_query (or the alias to_param if you prefer).
Post a Comment