Daddy hasn't got a brand new bag

May 13th, 2008 by ymendel 2 comments »

That title sucks. Sorry.

First and foremost, a shout-out goes to “Intense” Chris Bailey for being, as far as I know, one of the few people who care about and use Object Daddy, or at least he talks about it. Thanks to his interest, some problems got shaken out and some behavior tightened up.

Thanks to GitHub’s social networking-ness, Chris probably already knows about this, but it’s worth telling the whole world (as I refer to blogicx readership): Object Daddy has some updates to talk about.

I. generate/generate! no longer have this weird difference of one just making the object and the other saving as well as raising an exception if something went wrong. A new method, spawn, was made to handle the case of making a new object (analogous to new) and generate/generate! are now like create/create!.

A. It was mentioned before that STI and inheritance work nicely with generators, subclasses inheriting generators from parent classes but being able to define their own overrides. Well, that had a bug that relied on the classes being loaded in a certain order. That’s been fixed.

א. Generating an object through an association now works as expected. Take the following Category and Item models.

class Category < ActiveRecord::Base
  has_many :items

class Item < ActiveRecord::Base
  belongs_to :category
  validates_presence_of :category

No longer will some_category.items.generate create a new item that belongs to a new category. No, that item will belong to some_category.

Kudos and cheers all around, and keep on, uh, Daddying.

Or whatever.

2 Responses to “Daddy hasn't got a brand new bag”

  1. Chris Bailey Says:

    Thanks for the enhancements. I’ve of course been tracking those on GitHub, and with that, have been able to ditch my own git branch/fork of ObjectDaddy, and use the main one. I definitely do use it, and like it a lot. I’m starting up another new web app next week, and plan to make use of OD there as well.

  2. Yossef Says:

    Yeah, I saw that you got rid of your own fork. I find it a little amusing that our first pull requested was “refused”, not because it was bad, but because it was a small thing that prompted a big change, making OD much better overall.

    OSS ftw

Leave a Reply