【问题标题】:Rails, Gon - You can't use Gon public methods for storing dataRails, Gon - 你不能使用 Gon 的公共方法来存储数据
【发布时间】:2017-09-26 09:28:22
【问题描述】:
尝试登录应用时出现以下错误:
You can't use Gon public methods for storing data
指向这段代码:
gon.current_user = { sn: current_user.sn }
你能帮我看看这段代码有什么问题吗?
我使用的是 Gon 的 5.2.3 版本。
【问题讨论】:
标签:
ruby-on-rails
ruby
gon
【解决方案1】:
通过重新定义解决:gon.env = Rails.env 到 gon.enviro = Rails.env
【解决方案2】:
我对 gon 也有类似的问题。
经过一番调查,我发现我在 Gemfile 中使用的是 gon ~> 5.2.0,当我更新 gems 时,它更新到了 5.2.3。
我认为在 5.2.3 中 current_user 已添加到公共方法列表中。
所以我把 gon ~> 5.2.0 改成了 gon 5.2.0,重新打包后问题就解决了。