Rails, Gon - 您不能使用 Gon public 方法存储数据

Rails, Gon - You can't use Gon public methods for storing data

尝试登录应用程序时出现以下错误:

You can't use Gon public methods for storing data

指向此代码:

gon.current_user = { sn: current_user.sn }

你能帮我看看这段代码有什么问题吗? 我使用的是 Gon 的 5.2.3 版本。

通过重新定义解决:gon.env = Rails.env to gon.enviro = Rails.env

我对 gon 也有类似的问题。

经过一番调查,我发现我在 Gemfile 中使用的是 gon ~> 5.2.0,当我更新 gems 时,它已更新到 5.2.3。

我认为在 5.2.3 中 current_user 被添加到 public 方法列表中。

所以我将 gon ~> 5.2.0 更改为 gon 5.2.0,然后重新捆绑,问题消失了。