# Nested Attributes and find\_or\_create

**URL:** <https://www.ruby-forum.com/t/nested-attributes-and-find-or-create/177097>\
**Category:** Rails\
**Created:** [October 11, 2009, 5:48pm UTC](https://www.ruby-forum.com/t/nested-attributes-and-find-or-create/177097 "2009-10-11T17:48:01Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![yankees26](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/y/eb9ed0/32.png) [@yankees26](https://www.ruby-forum.com/u/yankees26)\
**Post date:** [October 11, 2009, 5:48pm UTC](https://www.ruby-forum.com/t/nested-attributes-and-find-or-create/177097/1 "2009-10-11T17:48:01Z")

</div>

Hi,

I’m using the new Nested Attributes to edit my models. It’s a  
complicated relationship between 5 different models which are subclassed  
from a ‘Metadata’ model. They all have has\_and\_belongs\_to\_many  
relationships with the model I am trying to edit.

Unfortunately when I add a new nested attribute, it creates a new row in  
the database. I need it to check up and determine if there is already a  
nested attribute of the same name first. Is this possible?

I am exploring the find\_or\_create dynamic finder but I cannot figure out  
how to integrate it with the nested attributes.

Thanks very much for your time
