Use Gon in rails model

338 Views Asked by At

Before upgrading to rails 5 I had include Gon::GonHelpers in my model file. Now I get an error and I am not able to use the gon variable in my model.

I get the error message:

NameError: undefined local variable or method `gon' for ....

How can I get to use gon in my model? I have found many answers on how to include it in views and controller, but not in models. Thank you!

1

There are 1 best solutions below

0
On

Adding: include Gon::ControllerHelpers seems to solve the problem