Since McAfee is offline due to some construction, Robb and I took ourselves off to a cafe and are taking the opportunity to continue learning a new web development technology called Ruby on Rails, or RoR for short. (If you’ve used any 37Signals product, or Twitter, you’ve been using a webapp developed on RoR.)
Both of us learn best by doing, so we are each building some smaller sites using RoR, in addition to actually developing a new web service for Lewis & Clark using it. Beyond all the CS technical jargon, like MVC, the best thing about RoR is that for us doing the coding on the back end, it creates an environment which automatically handles a lot of the messy technical details (like talking to databases) for us, allowing us to focus instead on the experience we want to give our users. What a concept.
And, since the best thing since sliced-toast on the web is AJAX, or the ability to update a portion of the web page without reloading the whole thing, I thought I’d quickly outline how really easy that is to do with RoR.
First of all, I’ll assume you’ve already created a RoR app and done all your setup to create your first controller, say myajax. (A simple way to think about the controller is that it is the thing that “answers” when you ask for a web page at a particular address.) And, I’ll assume you’ve also used the scaffold command to create your default views. (Views are the templates for the web pages that you receive in your browser.)
So, that all sounds like a lot, but like I said above, once you’ve got RoR setup, it took about three commands and thirty seconds to complete all of that.
To do some AJAX, you start by including the standard prototype libraries in your view layout, all with a single method in the <head> of the web page:
<%= javascript_include_tag :defaults %>
Then, in the view template that you want to have the ability to be updated by the AJAX request, include one of the two primary remote call methods — form_remote_tag or link_to_remote — as the action that will initiate the update. (I’m new to this, so I’m sure that there are more, but these two cover most of it.) Naturally, you have to supply the :url parameter and perhaps some additional information for your request. That could look something like this:
<%= link_to_remote("Test AJAX!", :url =>{ :action => "hello" } ) %>
Elsewhere in the index view, I’ll also drop in a little html to demonstrate the update, say something like:
<div id="myinfo"><p>Update this!</p></div>
Then, close that file and create a new file called hello.js.rjs in the same myajax view folder. (Here, the proper thing to do would be to add a “hello” method to the myajax_controller, but it works without for this example, so we’ll move ahead.) In the new file, write a single line of code such as the following:
page.replace_html "myinfo" "<div><p>I have been updated!</p></div>"
Which, in all it’s glory, essentially says go replace the item on the page with the id of “myinfo” with this new stuff.
And now the big moment, fire up your app in mongrel (Ruby’s webserver) and load the index page. You’ll see the “Test AJAX!” link and the “Update this!” text, and if you click the link, you should see the text change to the new message “I’ve been updated.”
Admittedly, this example is really basic, but if you do a little investigation into RoR’s page method, along with everything you might learn about formats in the controller, you’ll see how easy this really is. (And I’m not even getting to the easy visual effects.) And don’t even think of comparing this to the “old way,” like writing your own javascript implementations, and the back-end database hooks.
Related Stuff
-
MooV: Using cutting edge Video phones and Software Video Phones - coupling all that with VoIP and empowering the disabled.
-
Moo Telecom: VoIP communications made easy - Ring anyway with the fun and ease of using a normal phone
-
TagR:Mobile Social Network with Real Time Locations Based services, and Ambience Intelligence, VoiP, IM, Skype, Googletalk, Mapping, Flickr, Events, Calendaring, Scheduling, SecondLife Support
-
ClearSMS : ClearSMS is a Web-based application that lets you send bulk SMS messages to your customers, contacts, or just about anyone.
-
Jajah:jah is a VoIP (Voice over IP) provider, founded by Austrians Roman Scharf and Daniel Mattes in 2005[1]. The Jajah headquarters are located in Mountain View, CA, USA, and Luxembourg. Jajah maintains a development centre in Israel.
-
Skype: It’s free to download and free to call other people on Skype. Skype the number one voice over ip software
- PrivatePhone: a free local phone number with voicemail and messages you can check online or from any phone.
1 Comment |Add your comment.
Hi,Using the latest technology, our expert RoR programmers can develop systems tailored to all your needs. With a team of expert professionals of Ruby on Rails (RoR) developers, we help you weight the advantages of Ruby on Rail solution.Thanks.
Your Comment ...
Name (required)
Email (required, hidden)
Website

