Posts Tagged ‘RoR’

Using STI with rails fixtures [TECH]

Wednesday, February 20th, 2008

This is the first of many technical posts to come. I’ve added TECH in the title to allow non-technical readers to ignore these posts at a glance.

I’m using single table inheritance (STI) pretty heavily in the rails apps I’m building. It makes complete sense to me and keeps everything organized. Unit testing is new to me and so I left it alone for a while. When I went to add fixtures to my STI models (which are all Lord of the Rings references thank you very much), I realized I didn’t know what to do. I did some research and thought I was so smart. I talked to another dev and he recommended just changing the class name from the unit test, but we ran into a problem. We need to be able to load our fixtures without the unit tests themselves. If I did that, it would try to load the fixtures into database tables that don’t exist. So, we did some research and discovered my initial research is right. Even with STI, the filename of the fixtures has to be the database table name that it will get loaded into. Then you just set the type correctly in the fixture and it gets loaded into the right object.

Aside: I’m posting this from TextMate as well. Since I’m programming my RoR apps in TextMate, seems easy enough to just post from here when I find something interesting.

Rebekah on Rails

Tuesday, January 29th, 2008

A few years ago, Mark started telling me about Ruby on Rails and I thought it sounded like the dumbest thing on earth.  I asked, “Why would I want a framework to do my job for me?”  Then I got a job in the real world.  Ya know, that world where we all have way too much to do in the time were given?  I realized, “Duh!  I want it to do my job because I don’t have time to do everything my job requires.”  It all started to make sense.  I’m now happily coding in Rails and loving it.  I’m using ajax here and there.  I switched from Eclipse to Textmate (which I can post more about separately if anyone wants).  If you’re doing web apps, feeling bogged down by change requests, and want to explore something new…OR you’re new to web apps and want to learn something cool, you should definitely check out RoR.