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.
Revisions
-
ahpook revised this gist
Sep 6, 2011 . 1 changed file with 12 additions and 6 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,12 @@ # 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 @@ -12,11 +18,11 @@ post '/lame' do 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 -
randomcamel revised this gist
Sep 6, 2011 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,6 +1,6 @@ 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). get '/lame' do erb :lame -
randomcamel revised this gist
Sep 6, 2011 . 1 changed file with 8 additions and 2 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -2,18 +2,24 @@ Sinatra 1.2.6 doesn't appear to properly handle multiple values for a form param 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. get '/lame' do erb :lame end post '/lame' do puts params.inspect puts request.inspect puts params[:select_multiple_values] end # or use curl -X POST 'http://localhost:8000/lame/?select_multiple_values=oink&select_multiple_values=foo&select_multiple_values=bar' <!-- lame.erb --> <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> -
randomcamel revised this gist
Sep 6, 2011 . 1 changed file with 3 additions and 1 deletion.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,6 @@ 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. post '/lame/' do puts params.inspect -
randomcamel created this gist
Sep 6, 2011 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,17 @@ 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. post '/lame/' do puts params.inspect puts request.inspect puts params[:select_multiple_values] end # or use curl -X POST 'http://localhost:8000/lame/?select_multiple_values=oink&select_multiple_values=foo&select_multiple_values=bar' <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> </form>