Skip to Content

Ajax and Ruby on Rails (Until 5am)

posted 02 Apr 2005

UPDATE: Demo offline permanently

UPDATE: I moved my development site to a workstation here at home. It is a slow old box so be gentle, it is serving a little under 10req/s, but it works.

LiveSearch
Over the last few weeks I have been seeing what I can do with Ruby on Rails. My conclusion? In the future I want to use RoR for web applications: PHP just isn't as fun after you have worked with RoR.

At the Open Source Lab I work on a project written in PHP/MySQL called Maintain (demo), it is a DHCP/DNS management tool that is used by Oregon State, the Open Source Lab, math.ku.edu, and several others. It is a really great package, and one that many people are getting joy out of using. And given its size and complexity and my familiarity with its code, it made a great canidate for me testing out RoR.

Last night I decided to add LiveSearch support into my little pet project that is exploring how I would implement some of Maintains features in RoR. The first thing that needed to be done was add search methods to my models. Browsing around Tobias' typo source tree I figured out how I wanted to implement searching for one of my domain class and came up with this:

The line with r = find_by_sql( is something that is just amazing to me, and would have required a whole looping structure and some if statements to implement in PHP, but in Ruby I was able to use prepared statements, Array#join, and the * operator on the array to quickly build a restraint on the domains; all in one line.

After implementing the search methods, and looking at the Typo code the rest was a breeze, I created a couple of partials for live search results, and now with two lines of code I can add new objects to the LiveSearch sidebar. Very cool.

If you want to take a look at it in action click here (site down permanently, code available here). The handshake starts with a testguy and ends with a testt. Oh, and this is a limited time offer, the site is running on my laptop.

And speaking of the OSL Scott Kveton has made a great post about OSU's College of EECS strategy to take on the big research schools and focus less on undergraduate education. Its pretty clear that they should be focusing on open source software and education especially given the current climate around the state but I guess they would rather Go Big than think smart.

topics: ruby, maintain, dhcp, dns, ror

blog comments powered by Disqus

About

Brandon Philips by Mujtaba Ali

ifup.org is the weblog of Brandon Philips and contains excerpts from my code, work and play.

I write Linux software and work on the systems layer of Linux. In the last two years I have helped to organize Linux Plumbers Conf and Freedom HEC Taipei. It has been rewarding to bring together these communities to discuss current Linux issues.

Robotics is another passion and I had the opportunity to mentor a FIRST Robotics team in Portland recently too. I also continue to work with my friend Ron Jackson to build some neat USB devices for robotics.