Rails UTF-8中的无效字节序列(ArgumentError)

时间:2015-04-10 06:42:15

标签: ruby-on-rails

我正在做的只是从服务器下载的代码中rails s,它运行没有问题,但是它很顽固地通过这个错误

rails s
=> Booting Thin
=> Rails 4.0.2 application starting in development on http://0.0.0.0:3000
=> Run `rails server -h` for more startup options
=> Ctrl-C to shutdown server
Exiting
/usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/builder.rb:36:in `[]': invalid byte sequence in UTF-8 (ArgumentError)
    from /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/builder.rb:36:in `parse_file'
    from /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/server.rb:277:in `build_app_and_options_from_config'
    from /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/server.rb:199:in `app'
    from /usr/share/rvm/gems/ruby-2.1.4/gems/railties-4.0.2/lib/rails/commands/server.rb:48:in `app'
    from /usr/share/rvm/gems/ruby-2.1.4/gems/rack-1.5.2/lib/rack/server.rb:314:in `wrapped_app'
    from /usr/share/rvm/gems/ruby-2.1.4/gems/railties-4.0.2/lib/rails/commands/server.rb:75:in `start'
    from /usr/share/rvm/gems/ruby-2.1.4/gems/railties-4.0.2/lib/rails/commands.rb:76:in `block in <top (required)>'
    from /usr/share/rvm/gems/ruby-2.1.4/gems/railties-4.0.2/lib/rails/commands.rb:71:in `tap'
    from /usr/share/rvm/gems/ruby-2.1.4/gems/railties-4.0.2/lib/rails/commands.rb:71:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

对我来说,任何一点点帮助对我来说都是一个拯救生命的小窍门,用无数次安装和配置敲打我的脑袋几天。

提前致谢。

1 个答案:

答案 0 :(得分:0)

在您的gemfile中使用gem 'rack-utf8_sanitizer'gem "handle_invalid_percent_encoding_requests"并运行bundle