gazay / gon

Your Rails variables in your JS
MIT License
3.05k stars 184 forks source link

How do you assign variables to gon in a view #220

Open cmendla opened 7 years ago

cmendla commented 7 years ago

I need to be able to assign/change gon variables in a view. I did find something about how to do that but couldn't find it again.

I tried

<%= @gon.namespace = {
        :vartest => "1234"
      }
%>

but that gave me an error of

NoMethodError in SlitterBedsheets#show

My goal is to assign a global variable from a view.

thanks

p12y commented 7 years ago

If I remember correctly, you can use global variables for this. For example, Gon.global.variable = '1234'.