Forked from randomcamel/sinatra-multiple-values-fail
Created
September 6, 2011 21:32
-
-
Save ahpook/1199036 to your computer and use it in GitHub Desktop.
Sinatra failing to produce multiple param values
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Sinatra 1.2.6 doesn't appear to properly handle multiple values for a form parameter. 'params[:my_param_name]' | |
# only returns the last one supplied. I've verified that Chrome is sending the full list, and the list appears in | |
# the rack.request.query_string variable (but not the rack.request.params variable). | |
# This comes straight outta rack so it's not actually sinatra's fault. It's also undocumented magic in the | |
# rack/utils.rb#normalize_params method. | |
require 'rubygems' | |
require 'sinatra' | |
get '/lame' do | |
erb :lame | |
end | |
post '/lame' do | |
puts params.inspect | |
puts request.inspect | |
puts params[:select_multiple_values] | |
end | |
__END__ | |
@@ lame | |
<form method="POST" action="/lame"> | |
<select name="select_multiple_values[]" multiple size="5"> | |
<option value="First Option">Option 1 | |
<option value="Second Option">Option 2 | |
<option value="Third Option">Option 3 | |
</select> | |
<input type="submit"> | |
</form> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment