# Combine custom validations with helpers

**URL:** <https://www.ruby-forum.com/t/combine-custom-validations-with-helpers/126916>\
**Category:** Rails\
**Created:** [January 23, 2008, 12:58pm UTC](https://www.ruby-forum.com/t/combine-custom-validations-with-helpers/126916 "2008-01-23T12:58:22Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![makire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@makire](https://www.ruby-forum.com/u/makire)\
**Post date:** [January 23, 2008, 12:58pm UTC](https://www.ruby-forum.com/t/combine-custom-validations-with-helpers/126916/1 "2008-01-23T12:58:22Z")

</div>

Hi

I have a model that uses several validation helpers, for example  
validates\_presence\_of. Now I want to add a custom validate method for  
a very complex validation. I override validate in the model and it  
works by itself but when I do this the helper validations stop  
working. I guess the helper methods rely on the  
ActiveRecord::Base#validate original method in some way. Has anyone  
any suggestions on how to use both a custom validate and validations  
helpers?

Thanks in advance.

Erik L.

---

<div class="post-metadata">

**Author:** ![makire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@makire](https://www.ruby-forum.com/u/makire)\
**Post date:** [January 23, 2008, 6:23pm UTC](https://www.ruby-forum.com/t/combine-custom-validations-with-helpers/126916/2 "2008-01-23T18:23:26Z")

</div>

Instead of overriding the validate method call validate and pass it  
the name of your custom validation method. Here is an example:

class Foo \< ActiveRecord::Base  
validates\_presence\_of :bar  
validate :ensure\_some\_stuff

private  
def ensure\_some\_stuff  
# custom error checking here  
…  
end  
end

Aaron

---

<div class="post-metadata">

**Author:** ![makire](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/fbc32d/32.png) [@makire](https://www.ruby-forum.com/u/makire)\
**Post date:** [February 2, 2008, 12:38am UTC](https://www.ruby-forum.com/t/combine-custom-validations-with-helpers/126916/3 "2008-02-02T00:38:08Z")

</div>

Great, exactly the kind of solution I was looking for. Thanks.

/Erik
