Comments on: to_json and Rails 2 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/ with PHP or Rails and AJAX: From Novice to Professional Thu, 21 Jul 2011 18:22:51 +0000 http://wordpress.org/?v=2.3.3 By: Michael http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-123272 Michael Fri, 09 Apr 2010 07:41:55 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-123272 "var spots = ;" is what I meant... “var spots = ;”

is what I meant…

]]>
By: Michael http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-123271 Michael Fri, 09 Apr 2010 07:41:08 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-123271 anybody who is trying to get the examples running on rails 3 beta: rails 3 escapes erb by default. so make sure to use the raw method like this: var spots = ; anybody who is trying to get the examples running on rails 3 beta:

rails 3 escapes erb by default. so make sure to use the raw method like this:

var spots = ;

]]>
By: Jeff http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-103456 Jeff Tue, 21 Apr 2009 02:23:29 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-103456 Actually, never mind. I figured it out. Apparentally, the error I was getting was due to the loop that placed the markers on the map. I had to change the loop to look like: for (i = 0; i < stores.length; i++) { var store=stores[i].store; addMarker(store.lat, store.lng, store.name); } Actually, never mind. I figured it out. Apparentally, the error I was getting was due to the loop that placed the markers on the map. I had to change the loop to look like:

for (i = 0; i < stores.length; i++) {
var store=stores[i].store;
addMarker(store.lat, store.lng, store.name);

}

]]>
By: Jeff http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-103452 Jeff Tue, 21 Apr 2009 01:53:36 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-103452 I must admit that I'm a little confused, too, with regards to the example for 4-15. I've changed it from: var stores=; to var stores=; But it keeps giving me an "invalid argument" error. Any ideas? I must admit that I’m a little confused, too, with regards to the example for 4-15. I’ve changed it from:

var stores=;
to
var stores=;

But it keeps giving me an “invalid argument” error. Any ideas?

]]>
By: Max Smart http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-101494 Max Smart Tue, 07 Apr 2009 07:16:42 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-101494 I am using rails 2.2.2 and am only on chapter 3. I had to make this change to application.js var marker=markers[i].attributes to var marker=markers[i].marker and then it would pull the Markers already in the DB. Thanks, I am thrilled with this book. PS I do have a question. If I only wanted to allow ONE geocach site what would you recommend. This is what I did, but do not think it is a good idea. (the goal is to allow a user to select where they are from, but I only want to capture and store a single geocode - no addresses can be stored in the system) added to bottom of appl.js function oneTime() { removeListener(clicker) } window.onload = init; window.onclick = oneTime; window.onunload = GUnload; in init() I changed the GEvent.addListener.... to clicker = GEvent.addlistener... I am using rails 2.2.2 and am only on chapter 3. I had to make this change to application.js

var marker=markers[i].attributes to var marker=markers[i].marker

and then it would pull the Markers already in the DB. Thanks, I am thrilled with this book.

PS I do have a question. If I only wanted to allow ONE geocach site what would you recommend. This is what I did, but do not think it is a good idea.
(the goal is to allow a user to select where they are from, but I only
want to capture and store a single geocode - no addresses can be stored in the system)

added to bottom of appl.js

function oneTime() {
removeListener(clicker)

}

window.onload = init;
window.onclick = oneTime;
window.onunload = GUnload;

in init() I changed the GEvent.addListener….

to

clicker = GEvent.addlistener…

]]>
By: Toby Seaman http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-96697 Toby Seaman Tue, 03 Mar 2009 23:35:17 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-96697 joinlee, thanks for your August 16th post. I was completely stumped and unable to persuade my map to retrieve the points from the DB. I had pinned it down to a to_json type problem, but got lost working out how to debug. In the end it was a case of replacing .attributes with .marker. thank you so much for that gem! joinlee, thanks for your August 16th post. I was completely stumped and unable to persuade my map to retrieve the points from the DB. I had pinned it down to a to_json type problem, but got lost working out how to debug. In the end it was a case of replacing .attributes with .marker. thank you so much for that gem!

]]>
By: chris http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-87873 chris Tue, 20 Jan 2009 03:22:34 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-87873 You should link this from the errata-- I only found this page after spending a bunch of time trying to figure out why listMarkers() in chapter 3 didn't work and eventually figuring it out myself. I even came and looked at the errata page but it's not there. I only got here after googling "rails to_json" once I realized there was a difference in the structure in the book vs. what I was getting back. The upside: I learned more how to debug javascript and its interactions with rails. the downside: it took more time than I would have liked because I don't know much javascript and the way it deals with objects. You should link this from the errata– I only found this page after spending a bunch of time trying to figure out why listMarkers() in chapter 3 didn’t work and eventually figuring it out myself. I even came and looked at the errata page but it’s not there. I only got here after googling “rails to_json” once I realized there was a difference in the structure in the book vs. what I was getting back.

The upside: I learned more how to debug javascript and its interactions with rails.
the downside: it took more time than I would have liked because I don’t know much javascript and the way it deals with objects.

]]>
By: robert_d http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-85878 robert_d Fri, 26 Dec 2008 18:48:33 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-85878 @jeremy Put var stores = ; in map.html.erb (as it is explained above). Next see Page Source in a web browser to see what is the value of stores. @jeremy
Put
var stores = ;
in map.html.erb (as it is explained above). Next see Page Source in a web browser to see what is the value of stores.

]]>
By: robert_d http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-85767 robert_d Thu, 25 Dec 2008 18:35:24 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-85767 To see what Rails to_json function returns put this statement in javascript file alert('request.responseText :' + request.responseText); To see what Rails to_json function returns put this statement
in javascript file
alert(’request.responseText :’ + request.responseText);

]]>
By: jeremy http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-83456 jeremy Thu, 04 Dec 2008 19:17:24 +0000 http://www.googlemapsbook.com/2008/02/13/to_json-and-rails-2/#comment-83456 I am trying to test your code in example 4-15 with rails 2.0. I am seeing a syntax error when using json. In your updated example: you said to change the code to var stores=; to var stores=;. This is the same thing. :) I also used the new update on this site and it is different. var points=; This is also throwing an error. I am trying to test your code in example 4-15 with rails 2.0.

I am seeing a syntax error when using json.

In your updated example: you said to change the code to var stores=; to var stores=;. This is the same thing. :) I also used the new update on this site and it is different.

var points=;

This is also throwing an error.

]]>