Abe Burnett
2005-Apr-26 23:51 UTC
Good AJAX related example app source code or tutorials for Rails?
So, my other question for the day is regarding good places to delve into the mysteries of AJAX + Rails. I''ve found a couple of apps whose authors kindly offered the source code for download, thereby assisting me greatly in figuring out Rails in general, and some of how AJAX ties in, but I still feel like I''ve got big gaps in my knowledge. For those who might benefit from the couple of Apps with source code available as I did, they''re available here: http://www.rousette.org.uk/blog/archives/2004/11/28/rails-gtd-application/ http://darthapo.com/repos/taskthis.html Are there any other good examples of fleshed out applications from which to learn? Obviously, I''ve gone through all the tutorials on the RoR website, the onLAMP tutorial, the OReilly tutorial(s), etc... so what I''m looking for are BIGGER more complicated applications which really flex the Rails framework. Any examples of AJAX are just gravy I suppose. Any assistance is greatly appreciated. Perhaps some people can handle reading the API documentation, but I am not one of those... if I had 90% of the knowledge and just needed a refresher or a little tidbit then the documentation would work perfectly for that, but the lack comprehensive documentation... i.e. in the middle between super specific/technical and entry level tutorial... it can be difficult to get past the initial tutorials because they don''t do much for really implementing much beyond just the bare basics of Rails. Anyway, if one of the upcoming five Rails books was available I''m sure they''d help a lot to fleshing out my knowledge, ah well. June isn''t that far away, right? Ciao, Abe B. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Courtenay
2005-Apr-27 00:00 UTC
Re: Good AJAX related example app source code or tutorials for Rails?
On 4/27/05, Abe Burnett <abe.burnett-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> So, my other question for the day is regarding good places to delve into > the mysteries of AJAX + Rails. I''ve found a couple of apps whose authors > kindly offered the source code for download, thereby assisting me.. > *snip *IMO the key with ajax (or flash for that matter) is to keep it unobtrusive as possible, so that it becomes just another way to edit/update your data in-page (for example) rather than providing the whole basis of your UI. Rails is great for ajax because you are already rendering things as partials, so there''s very little additional code. A great example is the excellent blog software Typo [1], where commenting is done via ajax; you enter the details on the form, it updates the page with your comment. <tangent="on"> However (afaik) this doesn''t show you the comments that have been entered _since_ your last page load, so maybe a good way to learn ajax+rails would be to extend this functionality, and return all new comments in the same batch :) [2] That isn''t to say that ajax couldn''t be used for something cool like rendering partials from the *client* side, to take advantage of memcache/mod_cache/squid/something else that''s good at returning fast queries. If anyone''s interested in this, buzz me because I''m planning on working on it this week. </tangent> Is this what you had in mind? Or were you looking for a gmail-type app? --courtenay [1] http://typo.leetsoft.com [2] you''d probably do this by embedding a last_comment_id in the comment form, and return a collection of partials where id > last_comment_id.
Alexey Verkhovsky
2005-Apr-27 00:00 UTC
Re: Good AJAX related example app source code or tutorials for Rails?
Abe Burnett wrote:> Are there any other good examples of fleshed out applications from > which to learn?EliteJournal and RForum are the ones I am familiar with. Both are quite fully "fleshed out" as you put it :) -- Best regards, Alexey Verkhovsky Ruby Forum: http://ruby-forum.org (moderator) RForum: http://rforum.andreas-s.net (co-author) Instiki: http://instiki.org (maintainer)
Jeremy Kemper
2005-Apr-27 00:06 UTC
Re: Good AJAX related example app source code or tutorials for Rails?
Courtenay wrote:> <tangent="on"> > That isn''t to say that ajax couldn''t be used for something cool like > rendering partials from the *client* side, to take advantage of > memcache/mod_cache/squid/something else that''s good at returning fast > queries. If anyone''s interested in this, buzz me because I''m planning > on working on it this week. > </tangent>I''m not sure what you mean by rendering partials from the client side or how it could take advantage of a fast cache or proxy. Could you elaborate? Thanks! jeremy
Abe Burnett
2005-Apr-27 00:30 UTC
Re: Good AJAX related example app source code or tutorials for Rails?
Courtenay wrote:>On 4/27/05, Abe Burnett <abe.burnett-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > >>So, my other question for the day is regarding good places to delve into >>the mysteries of AJAX + Rails. I''ve found a couple of apps whose authors >>kindly offered the source code for download, thereby assisting me.. >>*snip * >> >> > >IMO the key with ajax (or flash for that matter) is to keep it >unobtrusive as possible, so that it becomes just another way to >edit/update your data in-page (for example) rather than providing the >whole basis of your UI. Rails is great for ajax because you are >already rendering things as partials, so there''s very little >additional code. > >A great example is the excellent blog software Typo [1], where >commenting is done via ajax; you enter the details on the form, it >updates the page with your comment. > ><tangent="on"> > >However (afaik) this doesn''t show you the comments that have been >entered _since_ your last page load, so maybe a good way to learn >ajax+rails would be to extend this functionality, and return all new >comments in the same batch :) [2] > >That isn''t to say that ajax couldn''t be used for something cool like >rendering partials from the *client* side, to take advantage of >memcache/mod_cache/squid/something else that''s good at returning fast >queries. If anyone''s interested in this, buzz me because I''m planning >on working on it this week. > ></tangent> > > >Is this what you had in mind? Or were you looking for a gmail-type app? > >--courtenay > >[1] http://typo.leetsoft.com >[2] you''d probably do this by embedding a last_comment_id in the >comment form, and return a collection of partials where id > >last_comment_id. > > >Thanks very much for the thoughtful response Courtenay! I see a major strength of AJAX as being what it''s capable of doing client side. The primary thing I detest about web apps up to this point is the amount of traffic they generate, how every user action requires a request to the server and a page refresh. Talk about archaic! Or, at least it really seems about high time that we moved closer to behavior traditionally only available in software applications running from a users computer. AJAX blows my hair back because (as I understand it anyway), you can essentially allow the user to continue using your application while you put backend processes into the background, so that the user doesn''t have to wait for processing unless absolutely necessary. Like, I''m not sure at all what it''d take to actually do, but in the comment example you referred to regarding Typo it would make sense to accept the users comment and display it immediately, while in the background writing that comment to the database. Thus, no page refresh, and the user can continue to use the web page or the site as a whole without waiting for the process of storing the comment to occur. So, is it not currently possible (using available features) to render partials from the client side? And if not, what are the possible means of accomplishing such and the various reasons for doing it one way and not another? A very entertaining and enlightening tangent, btw. I''ll take a look at Typo and see what I can learn from it. Thanks for the suggestion! Ciao, Abe B. _______________________________________________ Rails mailing list Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org http://lists.rubyonrails.org/mailman/listinfo/rails
Courtenay
2005-Apr-27 00:34 UTC
Client-side caching with ajax Was: Good AJAX related example app source code or tutorials for Rails?
hey bitsweat! on my box, apache + mod_cache easily churns out 1200 requests/second whereas rails on its own is about 12/second. (heavy lifting involved). so my theory was, why not use the fast apache memory-caching to cache some partials or actions, and spit them back without having to go through the whole rails overhead? sure, you use some more tcp sockets, but it might make sense. note that I haven''t actually tried this, :) this is intended for a community site where some of the data is user-specific (like, being able to edit things, or browser detection) but most can be cached for everyone. I got this idea after reading of Mozilla''s woes with caching--where people would get old data (based on server-side browser sniffing). So you set up the page, with the user stuff, and empty containers, and inside the page is some javascript which contains ajax calls, which fill out the rest of the page. note that this does NOT break the back button, because you''re still viewing html pages; just that parts of the content are filled out with an ajax call.. and hopefully it all degrades back flat. 1] you set up a controller in rails that returns just the partial, just like you would with a form update 2] in your html, you setup a window.onload that does an ajax call 3] ..which fills out the relevant containers. hope this makes some sense. --courtenay On 4/27/05, Jeremy Kemper <jeremy-w7CzD/W5Ocjk1uMJSBkQmQ@public.gmane.org> wrote:> Courtenay wrote: > > <tangent="on"> > > That isn''t to say that ajax couldn''t be used for something cool like > > rendering partials from the *client* side, to take advantage of > > memcache/mod_cache/squid/something else that''s good at returning fast > > queries. If anyone''s interested in this, buzz me because I''m planning > > on working on it this week. > > </tangent> > > I''m not sure what you mean by rendering partials from the client side or > how it could take advantage of a fast cache or proxy. Could you elaborate? > > Thanks! > jeremy >
Courtenay
2005-Apr-27 00:52 UTC
Re: Good AJAX related example app source code or tutorials for Rails?
> Thanks very much for the thoughtful response Courtenay! I see a major > strength of AJAX as being what it''s capable of doing client side. The > primary thing I detest about web apps up to this point is the amount of > traffic they generate, how every user action requires a request to the > server and a page refresh. Talk about archaic! Or, at least it really > seems about high time that we moved closer to behavior traditionally > only available in software applications running from a users computer. > AJAX blows my hair back because (as I understand it anyway), you can > essentially allow the user to continue using your application while you > put backend processes into the background, so that the user doesn''t have > to wait for processing unless absolutely necessary.the problem is, if you keep browsing (move away from the page), any requests you sent are possibly cancelled. actually, in my apps i especially like to use ajax for deleting rows in scaffold tables. you hit "delete" and the delete button changes to text, "deleting..." thus preventing it from being clicked. then when the action is successful, the whole row fades/squishes/hides from view. I think I wrote this up on the ror wiki. The same with saving; the line is re-rendered *from the db as a partial* to maintain consistency - that way you know your data is saved the way you want.> Like, I''m not sure at all what it''d take to actually do, but in the > comment example you referred to regarding Typo it would make sense to > accept the users comment and display it immediately, while in the > background writing that comment to the database. Thus, no page refresh, > and the user can continue to use the web page or the site as a whole > without waiting for the process of storing the comment to occur.you actually *do* want to hang around for errors, db problems, validation problems. so rendering straight to the page isn''t necessarily such a good idea. note that there is no "best practice" way of handling errors at this stage... --courtenay
Dee Zsombor
2005-Apr-27 07:08 UTC
Re: Client-side caching with ajax Was: Good AJAX related example app source code or tutorials for Rails?
On 4/27/05, Courtenay <court3nay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> on my box, apache + mod_cache easily churns out 1200 requests/second > whereas rails on its own is about 12/second. (heavy lifting involved). > so my theory was, why not use the fast apache memory-caching to cache > some partials or actions, and spit them back without having to go > through the whole rails overhead?Does mod_cache gives you something more than the webserver independent rails caching? How did you measure that 12 request/second? Zsombor -- http://deezsombor.blogspot.com
Courtenay
2005-Apr-27 08:44 UTC
Re: Client-side caching with ajax Was: Good AJAX related example app source code or tutorials for Rails?
On 4/27/05, Dee Zsombor <dee.zsombor-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:> On 4/27/05, Courtenay <court3nay-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote: > > on my box, apache + mod_cache easily churns out 1200 requests/second > > whereas rails on its own is about 12/second. (heavy lifting involved). > > so my theory was, why not use the fast apache memory-caching to cache > > some partials or actions, and spit them back without having to go > > through the whole rails overhead? > > Does mod_cache gives you something more than the webserver independent > rails caching? How did you measure that 12 request/second? > > ZsomborThe reqs/second I got from running ab. The in-rails caching I haven''t measured; I guess it''s likely that using the in-rails caching is just as fast for the relevant fragments? I haven''t tested this, and don''t really know how to. Which is where you guys come in ;) My vague calculations work on the idea that you can run two apps, one "Generic" with sessions disabled (for the performance boost) and one, smaller app "User" with just the session-relevant code. Starts to get mightily complex! The idea was that you can''t beat the webserver cache for pure speed, even with rails caching or whatever, because with rails there''s still a bit of overhead, even in loading the cache.