Archive for February, 2007

February 26th, 2007

A Piece of Humble Pie

by Tim Cull

I recently stumbled across a blog written by a 93-year-old man. The blog itself is interesting, but this post:

http://dontoearth.blogspot.com/2007/02/my-grandfather-and-others.html

in particular hit me in an unexpected way. Specifically, here’s a guy who remembers *first hand* using a horse and buggy to get around, and now he’s writing on a blog. Technology has evolved that far in the span of a single lifetime

That’s humbling.

It’s humbling because it gives me some perspective on the technology I create today. How long will its life be? How big will its impact be? Chances are, not as long or as big as I think–more likely it will be obsolete in a few years and completely forgotten in ten.

February 7th, 2007

When in Rome…

by Tim Cull

Day one of my new Rails application (let’s call it mystats) has been very productive. In a few hours, I have a complete set of (ugly) web pages for entering and browsing directly through my tables.

The first observation I had was that Rails assumes that your database tables are named in the plural. So, for example, it expects a table named “registered_users” instead of “registered_user”. This is mildly annoying to me, since I’ve always considered the “s” to be implied and therefore redundant, but I’m trying to be Rails-y here, so I’ll go with it. One thing that is
cool, though, is that it correctly converts “person” to “people”.

I also initially fought the Ruby convention of using underscores in table names. I’ve traditionally named tables by using all lowercase, with all the words smashed together (eg registerduser instead of registered_user). This turned out
to cause a little bit of a mess when I generated my model (eg. I ended up with a class called Registereduser instead of RegisteredUser), so I had to finally cave in.

I also learned something about MySQL, which is that if you use the MyISAM engine, you can’t have foreign keys. Annoyingly, it will let you try to specify one in your script and happily execute it with no errors. You just won’t end up with the foreign keys you were expecting.

The default pages that Rails generates don’t do anything special for fields that have foreign key relationships. What would be nifty is if it automagically generated a drop-down or a link to a search page. Maybe there are plugins for that, who knows.

My first bit of research will be to figure out how to do many-to-many relationships.
For example, I’ve got a many-to-many relationship between people and groups that I’ve
represented in the database with a mapping table:

people 1->n person_group n<-1 group

Rails generated a different class for each table, but in reality I’d prefer my object
model to only have a Person and a Group, with each of them containing a collection
of the other. Maybe that, too, isn’t very Railsy, but I guess I’ll find out.

Over all, though, it was a very productive day as Rails promises. I bought a book today so I can be more productive on the bus to and from work–hopefully that means even more progress to come!

February 6th, 2007

My First Ruby on Rails project

by Tim Cull

So, keeping up with the fine tradition of tech blogs everywhere, I’m planning to start a new project and document my progress on it here.

The project is to build a web site that I can use to keep track of my family and friends in case of a disaster or some other event. The idea is that if there’s, say, an earthquake in the middle of the day, my wife and my kids and I are likely to be spread all over the SF Bay Area and the local phone system is unlikely to work. I’m planning to build something that will allow us to check in and basically say “I’m ok” or “I’m not ok” or “I’m in transit and will probably be ok.” I want us to be able to check in via text message, email, visit to a web site, or (this will probably be a stretch) phone call and have the site log the checkin.

Technology-wise, this should be easy (minus the phone call part). And if what I’ve read about Rails is correct, using Rails should make it even easier.

To start, I downloaded Rails from http://www.rubyonrails.org/down. I also installed the Rails plugin for Eclipse from RadRails.

Next, I came up with my database schema and started following the directions on the ONLamp article that the Rails website points to. I’m in the middle of that now, so we’ll see how it goes.