Yesterday’s Thoughts

March 28, 2005

Ruby On Rails Experiments

I have been playing around with Ruby and Ruby on Rails. Based on the examples that I see (like this one for instance, this looks like a lead pipe cinch for implementing a few similar projects of my own that have been hanging around for a while, namely my training log project, my GTD combined project and to do list tracker, and my time tracker. These projects are all fundamentally the same, there is is series of tasks, projected or completed, and including various associated data, to track, and some logic that governs managing the state transitions of these tasks and the planning and reporting of these tasks.

I followed through that tutorial and I thought I was pretty clued in to what was happening and why. So I jumped in to try it myself. Since the training log project has been kicking around in my mind the longest, I thought I would give that a go. In retrospect, this was probably a bad idea. I had done several fitful starts on this project and so I had an existing database schema and other architectural ideas, that maybe weren’t so easily adapted to an out-of-the-box Rails project. My second mistake was to install an update to Rails (0.11) between reading the tutorial and turning to my own work. This confused that analysis of the later problems no end.

The first gotcha that I encountered was that database schema. I had defined several Type tables that were used in other tables, there was a ActivityTypes table that listed all the different activity records that could appear in the Workouts table, a WorkoutTypes table that described the status of the workout (planned, library, or completed), etc. These tables may not ultimately be very useful in Rails, or maybe they will, but the problem is that I created these tables without following the ActiveRecord conventions – lower case, plural table names for objects, the primary key should be a sequence named id, and foreign keys should be named lowercaseforeigntable_id. Instead of wiping the slate clean, I went in and fixed these problems one at a time. The combination of these two, with the intervening update of Rails was a mess.

Once I started over with reasonable incremental development practices, I was sailing smoothly, except it appears that Rails (WEBrick server) doesn’t clean up from old sessions, and by old, I mean really old. I was getting NoMethodErrors on every page that I attempted. This didn’t make any sense, but Goggle handed me the answer here. It seems like my earlier testing on the tutorial was sticking around and my new framework wasn’t being read.

The third obstacle was really very minor. In Curt Hibbs follow up to his Rolling on Rails, Part 2 he alluded to using the Rails generator to create the entire scaffold of an application. He doesn’t make a detailed mention, but base on what he said, I assumed that the scaffold :workout line would automatically be added to my controllers/workout_controller.rb file. Not so.

Now after, a few hours of productive work, and another few unproductive hours, I have a working application. Everything else is just stepwise refinement.

Sorry, comments for this entry are closed at this time.