# validating nested models

**URL:** <https://discuss.rubyonrails.org/t/validating-nested-models/58648>\
**Category:** rubyonrails-talk\
**Created:** [April 25, 2011, 10:58pm UTC](https://discuss.rubyonrails.org/t/validating-nested-models/58648 "2011-04-25T22:58:11Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ES1](https://avatars.discourse-cdn.com/v4/letter/e/919ad9/32.png) [@ES1](https://discuss.rubyonrails.org/u/ES1)\
**Post date:** [April 25, 2011, 10:58pm UTC](https://discuss.rubyonrails.org/t/validating-nested-models/58648/1 "2011-04-25T22:58:11Z")

</div>

Hi

I'm using Rails 2.3 and I want to validate that a nested model's attribute is numerical. How do I do that and then catch the error if there is one?

Thanks!

---

<div class="post-metadata">

**Author:** ![DK11](https://avatars.discourse-cdn.com/v4/letter/d/91b2a8/32.png) [@DK11](https://discuss.rubyonrails.org/u/DK11)\
**Post date:** [April 25, 2011, 11:07pm UTC](https://discuss.rubyonrails.org/t/validating-nested-models/58648/2 "2011-04-25T23:07:19Z")

</div>

> Hi
> 
> I’m using Rails 2.3 and I want to validate that a nested model’s
> 
> attribute is numerical.
> 
> How do I do that and then catch the error if there is one?

Give this a try, I think if you use the form builder and standard validation messages, as long as you have the validation in your nested model it should magically give you the error if a wrong value is submitted on a nested form. I have only started using this in rails 3 but I would guess it would work the same.
