Rails在redirect_to上使用有效网址的InvalidURIError

时间:2011-12-05 11:03:29

标签: ruby-on-rails ruby url redirect

我正在进行redirect_to ERROR URI::InvalidURIError: bad URI(is not URI?)。低于完整错误mgs

[2011-12-05 16:17:10] ERROR URI::InvalidURIError: bad URI(is not URI?): http://0.0.0.0:3000/list/#/items/offered/list/80-21614629999999,13-0468673/15/0?Filters={}
/home/ramesh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/generic.rb:746:in `rescue in merge'
/home/ramesh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/uri/generic.rb:743:in `merge'
/home/ramesh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpresponse.rb:163:in `setup_header'
/home/ramesh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpresponse.rb:101:in `send_response'
/home/ramesh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/httpserver.rb:86:in `run'
/home/ramesh/.rvm/rubies/ruby-1.9.2-p290/lib/ruby/1.9.1/webrick/server.rb:183:in `block in start_thread'

这是实际的网址

  

http://0.0.0.0:3000/list/#/items/offered/list/80-21614629999999,13-0468673/15/0?Filters= {}

我完全感到困惑,因为在我的制作环境中同样正常。

此外,如果我从网址中删除?Filters={}查询字符串部分,它在开发环境中工作正常。

我不明白为什么在dev env中使用?Filters={}时会抛出错误。有人可以澄清这个吗?

1 个答案:

答案 0 :(得分:0)

{}应该转义,并且以下网址有效:

http://0.0.0.0:3000/list/#/items/offered/list/80-21614629999999,13-0468673/15/0?Filters=%7B%7D

更新:

不,请检查http://tools.ietf.org/html/rfc3986

fragment    = *( pchar / "/" / "?" )
pchar         = unreserved / pct-encoded / sub-delims / ":" / "@"
unreserved    = ALPHA / DIGIT / "-" / "." / "_" / "~"
sub-delims    = "!" / "$" / "&" / "'" / "(" / ")"
                / "*" / "+" / "," / ";" / "="