Thursday, December 08, 2005

RoR & Foos together at last

Even as my spare time dwindles with the responsibilities of hosting the family Christmas celebrations at our house this year, I still try to find the time to continue my Ruby on Rails education. In 2005 I looked at a lot of technologies but RoR is one of the first to actually have me interested enough to do more than just read a book. Let me explain...

At work we have a foosball ladder which consists of a white board and a dry erase pen. While refreshingly low tech I thought "here's a problem just waiting to be automated with software!". Okay it doesn't really need software but it's a complex enough problem for me to get my feet wet with Rails. I unabashedly looked at the ladder options already on the web and (ahem) borrowed some of their ideas. I need to store information about players, teams, the ladders themselves, matches and the games in those matches and then I can go onto bells and whistles like enabling online challenge negotiations, the ability to mark a players status, and showing player/team stats.

So already I have several tables in a PostgreSQL database with a variety of relationships between them and I'm slowly figuring out what I can do with RoR's ORM tool ActiveRecord. So far I've been pretty happy with the support for optimistic locking, one-to-one (belongs_to & has_one), one-to-many (has_many), and many-to-many (has_and_belongs_to_many) relationships, dynamic finders, and transaction support.

I especially like being able to just play around in Ruby. I can mess with the tables, add and remove columns, change names, etc and then quickly see my changes take shape in my Ruby object model by running a simple Ruby script to create some objects and save them to the database. And no requirement to compile, or generate ORM XML mapping files has me feeling quite empowered.

No comments: