# Help with Many-To-Many insert

**URL:** <https://www.ruby-forum.com/t/help-with-many-to-many-insert/54328>\
**Category:** Rails\
**Created:** [March 1, 2006, 5:29pm UTC](https://www.ruby-forum.com/t/help-with-many-to-many-insert/54328 "2006-03-01T17:29:06Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![BuntinS\_SethSKATE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/77aa72/32.png) [@BuntinS\_SethSKATE](https://www.ruby-forum.com/u/BuntinS_SethSKATE)\
**Post date:** [March 1, 2006, 5:29pm UTC](https://www.ruby-forum.com/t/help-with-many-to-many-insert/54328/1 "2006-03-01T17:29:06Z")

</div>

I am having issues with a many-to-many table. The table relates  
resources to standards, but in my resources table has one-to-many  
relationships so those also appear in my many-to-many table. I am  
trying to insert into the table via:

@resource.core\_contents \<\< CoreContent.find(params[:core\_content\_ids])

But I get this error:

Mysql::Error: Duplicate entry ‘0-0-0-0-0-0’ for key 1: INSERT INTO  
core\_contents\_resources () VALUES ()

What is the problem?

Thanks for the help.

Seth B.

---

<div class="post-metadata">

**Author:** ![BuntinS\_SethSKATE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/77aa72/32.png) [@BuntinS\_SethSKATE](https://www.ruby-forum.com/u/BuntinS_SethSKATE)\
**Post date:** [March 1, 2006, 5:33pm UTC](https://www.ruby-forum.com/t/help-with-many-to-many-insert/54328/2 "2006-03-01T17:33:06Z")

</div>

On 3/1/06, Buntin, Seth - KATE [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> 

It seems that you have defined five fields of that table UNIQUE. Since  
you  
already have a record in that table with value 0 in each of those, no  
more  
records can be inserted with such values.

Thanks for the help.

---

<div class="post-metadata">

**Author:** ![BuntinS\_SethSKATE](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/b/77aa72/32.png) [@BuntinS\_SethSKATE](https://www.ruby-forum.com/u/BuntinS_SethSKATE)\
**Post date:** [March 1, 2006, 5:40pm UTC](https://www.ruby-forum.com/t/help-with-many-to-many-insert/54328/3 "2006-03-01T17:40:30Z")

</div>

Thanks. I took off the primary keys and it filled every row and value  
with a zero. It seems to be the right number of rows for that  
particular entry but the fields aren’t right. That isn’t what is  
suppose to have it is suppose to fill with the ids.

Rodrigo A. wrote:

> On 3/1/06, Buntin, Seth - KATE [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:
> 
> > 
> 
> It seems that you have defined five fields of that table UNIQUE. Since  
> you  
> already have a record in that table with value 0 in each of those, no  
> more  
> records can be inserted with such values.
> 
> Thanks for the help.
