Skip to content

Commit

Permalink
Symbol params back in thanks to Jeremy Evans
Browse files Browse the repository at this point in the history
  • Loading branch information
Blake Mizerany committed Apr 8, 2008
1 parent 74bfd99 commit 98572b4
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 5 additions & 2 deletions lib/sinatra.rb
Expand Up @@ -587,9 +587,12 @@ def initialize(request, response, route_params)
end

def params
@params = @route_params.merge(@request.params)
@params ||= begin
h = Hash.new {|h,k| h[k.to_s] if Symbol === k}
h.merge(@route_params.merge(@request.params))
end
end

def stop(*args)
throw :halt, args
end
Expand Down
19 changes: 19 additions & 0 deletions test/sym_params_test.rb
@@ -0,0 +1,19 @@
require File.dirname(__FILE__) + '/helper'

context "Symbol Params" do

setup do
Sinatra.application = nil
end

specify "should be accessable as Strings or Symbols" do
get '/' do
params[:foo] + params['foo']
end

get_it '/', :foo => "X"
assert_equal('XX', body)
end

end

0 comments on commit 98572b4

Please sign in to comment.