Problem extending ActiveRecord with custom validations

I'm having a problem extending ActiveRecord with custom validations based on the "Write Custom Validations" recipe from Advanced Rails Recipes. As far as I can tell, I've followed the instructions exactly but for some reason this isn't working and it's driving me crazy. I've tried making the methods in the custom validations module class methods (self.validates...) as well as the way they are below (which is the way they are in the instructions).

Any suggestions?

Thanks! Gavin

I'm having a problem extending ActiveRecord with custom validations based on the "Write Custom Validations" recipe from Advanced Rails Recipes. As far as I can tell, I've followed the instructions exactly but for some reason this isn't working and it's driving me crazy. I've tried making the methods in the custom validations module class methods (self.validates...) as well as the way they are below (which is the way they are in the instructions).

Any suggestions?

Have you tried requiring it from an initializer, not the bottom of
environment.rb ?

Fred

Thanks Fred, that worked! I created config/initializers/ custom_validations.rb and moved the require line there from the environment.rb file. It's not clear to me why this works, and it seems like it's overkill to create a new file for this, but as long as it works it's cool with me.

Thanks again. -Gavin

Thanks Fred, that worked! I created config/initializers/ custom_validations.rb and moved the require line there from the environment.rb file. It's not clear to me why this works, and it

Short version: because it means the require will happen at the right time. Long version: environment.rb and requiring dependencies - Space Vatican

Fred

Thanks Fred, interesting blog post!