Please read for an updated status on RailsCasts:
Learn more or hide this
it's really nice to have jquery in rails3.
thanks for this Ryan!
great one as always..
is there a simple way to make it a pull and not a push, so the server will not get lots of hits.. (you said something about a socket.. is this is the only way?)
it will be nice to have something as Gmail notify only when a new msg arrived.
Elad, I'm guessing you actually meant that you want server push and with Rails combined with Nginx there is one way forward with a HTTP push module for Nginx: http://github.com/slact/nginx_http_push_module
Here's an article describing how it could work: http://www.igvita.com/2009/10/21/nginx-comet-low-latency-server-push/
Elad, you can use WebSockets: http://en.wikipedia.org/wiki/WebSockets
I've had a lot of success switching my polling-based notification system to node.js & faye. Database traffic dropped by over 70% for my app, since node could push the data and completely avoid the db. Crazy!
Thanks so much for this! I wish I had seen this before.. I'm going to go redo my comments area now! By the way, did you experience any issues upgrading to Rails3?
Practical and straightforward as usual. Thanks, Ryan.
This is easy to implement by listening for AJAX events, as detailed here:
Just a thought. Thanks again for the great screencast.
Great episode! But I noticed that you are using clas selector in jquery, which is very slow in IE. I think it's better to write at least like this one:
Just put the element before the class name and it will improve the performance.
Best to display it to the user as a progress bar in my opinion. That way you keep him distracted instead of just displaying a 'please wait' message :)
Great screencast as usual. Nothing new to me (as I earn my beard by writing jQuery), but I sent it to a friend, which was curios how to do Ajax.
Do you plan to add a Flattr button to your page? Flattr a smart mix between the like button and donating, but not as clumsy as Paypal and it's getting very popular in Europe right now. I would click every single episode!
Regards from Germany,
Thanks Javi. Good to know.
@Greg @Igor Thanks!
I know "push" is a bit of a buzz word at the moment but it's completely justified and you really should give it a try.
Using Pusher - http://pusherapp.com - you get WebSockets (and a Flash fallback) that can be integrated with your Rails app with just a few lines. Check out the quickstart guide http://pusherapp.com/docs/quickstart to see how easy it is. You also get instant feedback - no waiting for 10 seconds - and less load on your server to boot!
Disclaimer: I work at New Bamboo who are the guys behind Pusher.
i find it a nice trick
Thanks for the great things you're doing! :)
I have a question about this episode.
In the controller code in where condition you compare created_at with Time.at(params[:after].to_i + 1). In rails 2.3.8 datetimes are stored in utc in DB, and Time.at(...) would return a time in the system timezone so inserting Time.at into where condition without explicitly converting it to utc would produce incorrect resulting query. Did they change the way conditions work in rails3?
Thanks Ryan for this. I was just working om something like this for one of my projects.
Have you seen Robert Fischer jQuery port of PeriodicalUpdater ( http://github.com/RobertFischer/JQuery-PeriodicalUpdater ) That can do what you build yourself here with just a small change :-)
Please look at it, I found it very usefull.
What about an RJS template instead? It would cut down on the js awkwardness and would be compatible with respond_with.
@Mike That would mean going to prototype, unless you use something like jrails, not sure if its compatible with Rails 3.
Chainging isn t so Ok. Maybe do something else. It is more secure.
This is nice but isn't the more modern way of doing this using a web socket or something like comet?
Any chance of adding a HTTP streaming webcast :) with something like orbited or APE?
Ryan (or anyone): One question: The client is effectively doing a GET, right? And GETs are supposed to be idempotent (not change the state on the server). Do you have to do anything special to tell the server's cacheing mechanisms that a GET on the same URI twice in a row might yield different results? Or is it just luck that the &after= query parameter has that effect (since it changes continually)?
Hi everyone, can somebody take a look in this question:
I'm trying to update a lightbox, instead of the normal view.
where can I find a revised and updated demo/tut for something like Rails3.1.2 "polling-for-changes" like this great but not updated screencasts: http://railscasts.com/episodes/229-polling-for-changes?view=asciicast ?
answer also here if u want
First sign in through GitHub to post a comment.