From: Ken Ghosh Date: 2009-09-08T21:20:38+09:00 Subject: Re: accessing Name and value pair using "Sinatra" Jesús Gabriel y Galán wrote: > On Tue, Sep 8, 2009 at 9:00 AM, Ken Ghosh wrote: >> Hello everyone, >> >> � I currently using Sinatra nad i must say its great. >> � But I am currently stuck i wanted to passes a Name,value pair >> � as a parameter to sinatra >> >> � something like this >> � http://localhost:4567/multiQuery?&Name_1='ABC'&Name_2='XYZ'&Name_3='LMN' >> >> � so that i can directly access values 'ABC','XYZ' and 'LMN' > > There's a params attribute in Sinatra::Base that contains the query > string: > > This route: > > get '/hello/:name' do |name| > "Hello, #{name}. #{params.inspect}" > end > > when called as: > > http://localhost:4567/hello/x?a=3&b=4 > > produces: > > Hello, x. {"name"=>"x", "a"=>"3", "b"=>"4"} > > Hope this helps, > > Jesus. can i get only parameters after the question '?' e.g http://localhost:4567/hello/x?a=3&b=4 as {"a" => "3","b" => "4"} also i want to know how can i return and xml content so that when i type http://localhost:4567/hello/x?a=3&b=4 the response should be presented in xml format -- Posted via http://www.ruby-forum.com/.