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

355 Views Asked by At

I have following error when try login in app:

You can't use Gon public methods for storing data

Pointed to this code:

gon.current_user = { sn: current_user.sn }

Can you help me what is wrong with this code? I am using version 5.2.3 of Gon.

2

There are 2 best solutions below

0
On BEST ANSWER

Solved by redefining: gon.env = Rails.env to gon.enviro = Rails.env

0
On

I had a similar issue with the gon.

After some investigation, I was able to find that I was using gon ~> 5.2.0 in Gemfile, and when I updated the gems it got updated to 5.2.3.

I think in 5.2.3 the current_user was added to public methods list.

So I changed the gon ~> 5.2.0 to gon 5.2.0, and rebundled and the issue was gone.