In ActiveRecord, a "has many" method for a class is what they call a
proxy object.  It sits there and does nothing until an access like
book.authors[0].first_name causes a database search for authors of the
book.  Once the query has completed, further uses do not cause a db
query (generally).

Has anyone done a similar concept for json objects?

For example, if I send book over as a json object, also send a method
called authors.  authors originally would be a method that would first
do an ajax call with the proper url back to the server to populate the
relation.  Subsequent uses would just use what has already been
fetched.  Right now, I'm wanting just read capability and not update
capability but it seems like update capability would be plausible as

What I don't know (because I don't know enough how browsers work) is
if you can pause the javascript thread and make the call synchronous
to that particular javascript thread or not.  Would such a synchronous
call cause the browser to hang?  And then there is the whole question
of retries and failure modes.

The other choice (which seems super hard) would be to kick off the
ajax call and basically do a context switch.  When the call completed,
find the context it is associated with and resume the path.

You received this message because you are subscribed to the Google Groups 
"Prototype &" group.
To post to this group, send email to
To unsubscribe from this group, send email to
For more options, visit this group at

Reply via email to