Forum: Ruby on Rails Help with Many-To-Many insert

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
E4c4a05719644c37f02dc5181de7c8c5?d=identicon&s=25 Buntin, Seth - KATE (Guest)
on 2006-03-01 17:29
(Received via mailing list)
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 Buntin
3bec49196b296ac7c201412642c7a2b1?d=identicon&s=25 Rodrigo Alvarez (papipo)
on 2006-03-01 17:33
(Received via mailing list)
On 3/1/06, Buntin, Seth - KATE <Seth.Buntin@coe.murraystate.edu> 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.
E4c4a05719644c37f02dc5181de7c8c5?d=identicon&s=25 Seth Buntin (Guest)
on 2006-03-01 17:40
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 Alvarez wrote:
> On 3/1/06, Buntin, Seth - KATE <Seth.Buntin@coe.murraystate.edu> 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.
This topic is locked and can not be replied to.