Rails 关于 Rails 5 request.referer 为空的问题

ksegg · June 13, 2019 · Last by ksegg replied at June 14, 2019 · 1899 hits

Rails.application.routes.recognize_path(request.referer)[:controller]

上面代码是取得跳转之前的 controller,Rails5.0 时没有问题,当我 Rails 升级到 5.1.6 时,出现下面的 error 信息:

*** NoMethodError Exception: undefined method `encoding' for nil:NilClass

原因是 request.referer 的值是 nil

请问各位大神如何解决?

win10 edge 会出现这种情况

Reply to BruceDing

win10 + IE

You need to Sign in before reply, if you don't have an account, please Sign up first.