# Validates\_associated

**URL:** <https://www.ruby-forum.com/t/validates-associated/173722>\
**Category:** Rails\
**Created:** [August 13, 2009, 9:47pm UTC](https://www.ruby-forum.com/t/validates-associated/173722 "2009-08-13T21:47:22Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 13, 2009, 9:47pm UTC](https://www.ruby-forum.com/t/validates-associated/173722/1 "2009-08-13T21:47:22Z")

</div>

Is the any way to get more descriptive of the errors associated with  
the associated model?

I have a site model that has:

validates\_associated :Eqptattrs

and below is the error generated from the associated model.

There were problems with the following fields:

```
* Eqptattrs is invalid
```

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 13, 2009, 10:46pm UTC](https://www.ruby-forum.com/t/validates-associated/173722/2 "2009-08-13T22:46:32Z")

</div>

Chris H. wrote:

> Is the any way to get more descriptive of the errors associated with  
> the associated model?
> 
> I have a site model that has:
> 
> validates\_associated :Eqptattrs
> 
> and below is the error generated from the associated model.
> 
> There were problems with the following fields:
> 
> ```
> * Eqptattrs is invalid
> 
> ```

If i were you, i would provide the model itself to help others  
investigate the issue clearly.

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 14, 2009, 1:40am UTC](https://www.ruby-forum.com/t/validates-associated/173722/3 "2009-08-14T01:40:03Z")

</div>

okie dokie

class Eqptattr \< ActiveRecord::Base  
belongs\_to :site  
belongs\_to :equipment

```
validates_presence_of :ip

```

end

class Site \< ActiveRecord::Base  
has\_many :eqptattrs, :dependent =\> :destroy  
has\_many :equipments, :through =\> :eqptattrs

```
validates_uniqueness_of :name
validates_associated :eqptattrs

```

end

class Equipment \< ActiveRecord::Base  
has\_many :eqptattrs, :dependent =\> :destroy  
has\_many :sites, :through =\> :eqptattrs  
end

On Aug 13, 3:46 pm, Rails L. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)

---

<div class="post-metadata">

**Author:** ![bigdaddy71](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/bbe5ce/32.png) [@bigdaddy71](https://www.ruby-forum.com/u/bigdaddy71)\
**Post date:** [August 14, 2009, 5:00pm UTC](https://www.ruby-forum.com/t/validates-associated/173722/4 "2009-08-14T17:00:43Z")

</div>

I also use this kind of validations in another project and I get the  
same general error. Is there a better way to handle these kind of  
association errors?
