处理请求时出现意外错误:UTF-8中的字节序列无效#

时间:2016-09-21 13:00:36

标签: ruby-on-rails ruby

启用rack-mini-profiler gem时,会出错

Unexpected error while processing request: invalid byte sequence in UTF-8
使用

 Rails v4.0.6

 rack-mini-profiler 0.10.1

 Ruby 2.2.0

仅在启用rake-mini-profiler时才会发生,否则应用程序正常工作。

回溯:

Unexpected error while processing request: invalid byte sequence in UTF-8

/home/aa/.rvm/gems/ruby-2.2.0/gems/rack-mini-profiler-0.10.1/lib/mini_profiler/client_settings.rb:24:in `split'
/home/aa/.rvm/gems/ruby-2.2.0/gems/rack-mini-profiler-0.10.1/lib/mini_profiler/client_settings.rb:24:in `initialize'
/home/aa/.rvm/gems/ruby-2.2.0/gems/rack-mini-profiler-0.10.1/lib/mini_profiler/profiler.rb:153:in `new'
/home/aa/.rvm/gems/ruby-2.2.0/gems/rack-mini-profiler-0.10.1/lib/mini_profiler/profiler.rb:153:in `call'
/home/aa/.rvm/gems/ruby-2.2.0/gems/railties-4.0.6/lib/rails/engine.rb:511:in `call'
/home/aa/.rvm/gems/ruby-2.2.0/gems/railties-4.0.6/lib/rails/application.rb:97:in `call'
/home/aa/.rvm/gems/ruby-2.2.0/gems/rack-1.5.5/lib/rack/content_length.rb:14:in `call'
/home/aa/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/lib/thin/connection.rb:86:in `block in pre_process'
/home/aa/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/lib/thin/connection.rb:84:in `catch'
/home/aa/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/lib/thin/connection.rb:84:in `pre_process'
/home/aa/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/lib/thin/connection.rb:53:in `process'
/home/aa/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/lib/thin/connection.rb:39:in `receive_data'
/home/aa/.rvm/gems/ruby-2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:193:in `run_machine'
/home/aa/.rvm/gems/ruby-2.2.0/gems/eventmachine-1.0.8/lib/eventmachine.rb:193:in `run'
/home/aa/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/lib/thin/backends/base.rb:73:in `start'
/home/aa/.rvm/gems/ruby-2.2.0/gems/thin-1.6.4/lib/thin/server.rb:162:in `start'
/home/aa/.rvm/gems/ruby-2.2.0/gems/rack-1.5.5/lib/rack/handler/thin.rb:16:in `run'
/home/aa/.rvm/gems/ruby-2.2.0/gems/rack-1.5.5/lib/rack/server.rb:264:in `start'
/home/aa/.rvm/gems/ruby-2.2.0/gems/railties-4.0.6/lib/rails/commands/server.rb:84:in `start'
/home/aa/.rvm/gems/ruby-2.2.0/gems/railties-4.0.6/lib/rails/commands.rb:76:in `block in <top (required)>'
/home/aa/.rvm/gems/ruby-2.2.0/gems/railties-4.0.6/lib/rails/commands.rb:71:in `tap'
/home/aa/.rvm/gems/ruby-2.2.0/gems/railties-4.0.6/lib/rails/commands.rb:71:in `<top (required)>'
bin/rails:4:in `require'
bin/rails:4:in `<main>'

我不确定,我认为这个错误会在'Slim-Rails'宝石

之后继续出现

1 个答案:

答案 0 :(得分:0)

刚刚添加

gem "handle_invalid_percent_encoding_requests"

工作正常!

来自https://stackoverflow.com/a/24894410/3212137

解决方案