Skip to content

Commit 2d6770a

Browse files
committed
Change example of gon.global
1 parent 11f9b06 commit 2d6770a

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

README.md

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -302,21 +302,24 @@ wouldn't work. You can read about this in common usage above.
302302
Now you can use gon for sending your data to js from anywhere!
303303

304304
It works just as simple `gon` but you need to write `Gon.global` instead of `gon` in your ruby code,
305-
`gon.global` in javascript and it will not clear self after each request. All other things the same.
305+
`gon.global` in javascript and it will not clear self after each request. All other things remain the same.
306306

307-
For example I want to tell anybody my application session secret token :) Now with Gon.global it's easy!
307+
For example I want to set start data into gon, which will be there before I clear it.
308308

309-
`config/initializers/secret_token.rb`
309+
Maybe some configuration data or url address which should be present on each page with `include_gon` helper in head.
310+
311+
Now with Gon.global it's easy!
312+
313+
`config/initializers/some_initializer.rb or any file where you can reach Gon constant`
310314

311315
```ruby
312-
GonTest::Application.config.secret_token = "You can't see my token"
313-
Gon.global.secret_token = "You can't see it I said"
316+
Gon.global.variable = 'Some data'
314317
```
315318

316319
`in some js which can reach window.gon variable`
317320

318321
```javascript
319-
alert(gon.global.secret_token)
322+
alert(gon.global.variable)
320323
```
321324

322325
Thats it!

0 commit comments

Comments
 (0)