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. Continue reading
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.
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.
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. Continue reading