Friday, March 27, 2009

before_create should return the right boolean!

This is a small thing, but I wasted an hour or so figuring this thing out. I had an a before_create where I set a boolean variable to false and then my tests started to fail? Why? Because before_create will stop the creation of the record if it returns false!


class A << AR::Base
before_create :set_enabled

def set_enabled
self.enabled = false
true # so that it doesn't fail
end
end

No comments: