ruby - A blank in the URI works in production but fails in development -
i have following code works in production:
redirect_to "/mycontroller/index.html#&panel1-2?error=invalid member id and/or date of birth"
in development(using webrick), getting following error message:
error uri::invalidurierror: bad uri(is not uri?): http://localhost:3000/mycontroller/index.html#&panel1-2?error=invalid member id and/or date of birth
but if copy , paste supposedly bad uri in browser address bar, works!
i have tried various combinations of error message text, , spaces between words causing it. can make work using uri.escape or other technique escape spaces, have change hundreds of such occurrences in code working fine.
thanks taking time help.
as shown below, uri invalid. can't have unescaped spaces in uri.
1.9.3p194 :001 > require 'uri' => true 1.9.3p194 :002 > uri.parse('http://localhost:3000/mycontroller/index.html#&panel1-2?error=invalid member id and/or date of birth') uri::invalidurierror: bad uri(is not uri?): http://localhost:3000/mycontroller/index.html#&panel1-2?error=invalid member id and/or date of birth /users/ccashwell/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/uri/common.rb:176:in `split' /users/ccashwell/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/uri/common.rb:211:in `parse' /users/ccashwell/.rvm/rubies/ruby-1.9.3-p194/lib/ruby/1.9.1/uri/common.rb:747:in `parse' (irb):2 /users/ccashwell/.rvm/rubies/ruby-1.9.3-p194/bin/irb:16:in `<main>'
you should escape
uri:
1.9.3p194 :003 > uri.escape('http://localhost:3000/mycontroller/index.html#&panel1-2?error=invalid member id and/or date of birth') => "http://localhost:3000/mycontroller/index.html%23&panel1-2?error=invalid%20member%20id%20and/or%20date%20of%20birth"
then can redirect_to
escaped uri:
redirect_to uri.escape('http://localhost:3000/mycontroller/index.html#&panel1-2?error=invalid member id and/or date of birth')
Comments
Post a Comment