tags:

views:

34

answers:

1

I am trying to use a question mark in one of my url's but sinatra/ruby is interpreting it as the regex character that makes precedings optional. Is there any way to allow actual ? in your get methods? I have tried \? and [?] but they didn't work. Here is the begining of my get method:

get '/group?groupid=:groupId' do |id|

If I go to www.mydomain.com/group?groupid=1 I get an error but it works if I go to www.mydomain.com/groupgroupid=1

+5  A: 

The "?" starts the querystring portion of the URL; querystring parameters are accessible via the "params" Hash.

Adam Vandenberg
To clarify, just use: get '/group' do; params[:groupid]; ...; end
Brian Deterling
For "/search?q=abc", use: get '/search' do q = params['q']
Adam Vandenberg