Search code examples
javascriptruby-on-railsrubygon

undefined local variable or method `env' for method in controller


I'm currently using 'gon' to pass my client id for payment to the javascript sdk of the payment gateway (Braintree in my case).

When I try to set the client id generated to a 'gon' variable, I'm facing this error.

Basically this is my code

def new
  gon.client_token = generate_client_token
end
.
.
.
private
def generate_client_token
  Braintree::ClientToken.generate
end

And I'm using 'figaro' for environment variables.


Solution

  • I had the same problem. My rails 5.2.3 and gon 5.2.3. After upgrading the gon to 6.2.0 the issue went away.