-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Thanks for sharing Donald, very nice resource! :)
Abrazo, Ibon. Usa Software Libre, tus úlceras te lo agradecerán Realizado con Software Libre. - -- GPG public key at http://sinanimodelucro.net/ibon_gmail.asc Finderprint: 1761 59B9 6DE6 0402 31B9 1872 178F A6FD 75F9 EB29 El 18/08/13 17:15, Donald Ziesig escribió: > Hi All! > > This is not directly related to Hobo, but it was so cool I just had > to pass it on. > > I needed to transfer large amounts of data from multiple models to > the view's javascript. I was anticipating spending days, if not > weeks, generating the necessary code. One very lucky google search > later, I found the "gon" gem. This gem of a gem (I couldn't > resist) takes data from ruby (e.g., array of arrays of arrays, > hashes containing arrays) and translates it into a > <script>....</script> containing the data in javascript code. > > In less than 20 minutes I had geographic data covering all of > central Florida and selected realestate listings moved from my db > tables to the view and processed by javascript code for display by > google maps. > > Just add > > gem "gon" # Converts ruby objects to javascript objects in view > !!!!! > > to your Gemfile (followed by bundle install). > > In the appropriate controller, setup the data then add: > > gon.listings = listings # An array of > hashes containing arrays of hashes gon.neighborhoods = > neighborhoods # An array of arrays of arrays gon.names = names > # An array of strings gon.nbh_id = nbh_id > # An array of integers. > > hobo_show # Plain old > Hobo > > Add to the view(s): > > <%= include_gon %> <!-- might want to covert this to a dryml tag > but its so simple... --> > > > Finally, use the data in javascript files: > > poly = new google.maps.Polygon( { name: gon.names[i], nbh_id: > gon.nbh_id[i], strokeColor: "#000000", strokeOpacity: 0.8, > strokeWeight: 1, fillColor: "#000000", fillOpacity: 0.0, paths: > gon.neighborhoods[i] }) > > If this is useful to anyone, let me know. With sufficient interest > I might even add it as a recipe ;) > > Don Ziesig > -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.11 (GNU/Linux) Comment: Using GnuPG with Thunderbird - http://www.enigmail.net/ iEYEARECAAYFAlIR3IkACgkQF4+m/XX56ymsYQCfTQa/dYj0Ezf/jXKtHWnYcbJV IRYAn36Z/mdfVE8I/CtkPYUx6RGVBvNI =ALK6 -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Hobo Users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/hobousers. For more options, visit https://groups.google.com/groups/opt_out.
