Passing data to javascript using gon and jbuilder in Rails

Sometimes it is required to pass some data from server-side code to client-side javascript code.

There is a gon gem for that and it has pretty good manual. Nevertheless, I had some issues using this gem, so I decided to share my experience.