# Validation with has\_one associated models

**URL:** <https://www.ruby-forum.com/t/validation-with-has-one-associated-models/113883>\
**Category:** Rails\
**Created:** [September 5, 2007, 9:52pm UTC](https://www.ruby-forum.com/t/validation-with-has-one-associated-models/113883 "2007-09-05T21:52:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 5, 2007, 9:52pm UTC](https://www.ruby-forum.com/t/validation-with-has-one-associated-models/113883/1 "2007-09-05T21:52:09Z")

</div>

Is Rails designed to validate differently with the has\_one model  
association or is it a bug? I find myself having to code around my  
validation differently and wasn’t sure if others thought it was an  
issue as well.

For example if employee HAS\_ONE manager:

my\_employee.manager = invalid\_manager  
my\_employee.save  
=\> true

Shouldn’t my\_employee.save return false since the invalid\_manager was  
unable to save?

Thanks,  
Tom

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [September 5, 2007, 10:38pm UTC](https://www.ruby-forum.com/t/validation-with-has-one-associated-models/113883/2 "2007-09-05T22:38:12Z")

</div>

On 9/5/07, TomRossi7 [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> =\> true
> 
> Shouldn’t my\_employee.save return false since the invalid\_manager was  
> unable to save?

you need to use validates\_associated

[http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M000948](http://api.rubyonrails.com/classes/ActiveRecord/Validations/ClassMethods.html#M000948)

Adam
