Archive for the ‘Programming’ Category

DataMapper Associations Dilemma

Wednesday, November 3rd, 2010

I’ve been working with DataMapper and trying to use associations between models Project and Task. I had the models in separate files project.rb and task.rb. When I tried associating them with each other I got the following error:

Cannot find the parent_model Project for Task in project (NameError)

I gathered this was caused by project.rb requiring task.rb and vice versa, since the association worked fine if I just put the require in one of the files. (more…)

Dry Run – a quickie

Tuesday, October 26th, 2010

While I was enjoying all the down time (Kitties Ho!), I reasoned that it was probably best not to end up waiting half an hour every time I run my scripts, especially when I want to just test some small change in logic. I consulted our resident bash expert and he handed me this gem.


Sunday, October 24th, 2010

I often find myself wishing for a simple complete code example for a new tool, so here you go. DataMapper is an Object Relational Mapper (ORM) gem for Ruby based projects. It uses the active record design pattern, after which the ActiveRecord gem, popularized by Rails, is so accurately named. I’ll leave the details of what all that means to your own research, but in short, DataMapper is a tool intended to ease the use of databases in your Ruby applications, so you have to spend less time thinking in terms of SQL queries and can spend more time manipulating your objects.


Wednesday, October 20th, 2010

CruiseControl.rb is an excellent tool for continuous integration (CI). It runs a server and tries to build your project whenever you make a commit to your repository, reporting errors when they come up. Here I’ll show you how to get a basic project off the ground.

Boolean operators and Set operations

Wednesday, October 6th, 2010

Reviewing some Ruby code recently I came across an operator I hadn’t seen before: &&=. I guessed intuitively what it meant, judging from context and experience, but my Google-fu wasn’t up to the task of confirming my suspicions. (more…)