# Duplicate entry '1' for key 1

**URL:** <https://www.ruby-forum.com/t/duplicate-entry-1-for-key-1/128180>\
**Category:** Rails\
**Created:** [February 5, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/duplicate-entry-1-for-key-1/128180 "2008-02-05T16:47:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaizerkaizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@kaizerkaizer](https://www.ruby-forum.com/u/kaizerkaizer)\
**Post date:** [February 5, 2008, 4:47pm UTC](https://www.ruby-forum.com/t/duplicate-entry-1-for-key-1/128180/1 "2008-02-05T16:47:07Z")

</div>

I’m used the attachment\_fu plugin, something has gone wrong here as I  
tried to upload a picture.

ActiveRecord::StatementInvalid in PortfolioController#create

Mysql::Error: #23000Duplicate entry ‘1’ for key 1: INSERT INTO  
portfolios (`content_type`, `size`, `thumbnail`, `filename`, `height`,  
`parent_id`, `width`) VALUES(‘image/jpeg’, 45256, ‘thumb’,  
‘godjesus\_thumb.jpg’, 81, 1, 100)

as I try it a second time I recieve the same error except it states "  
entry ‘2’ " instead of " entry ‘1’ "

Mysql::Error: #23000Duplicate entry ‘2’ for key 1: INSERT INTO  
portfolios (`content_type`, `size`, `thumbnail`, `filename`, `height`,  
`parent_id`, `width`) VALUES(‘image/jpeg’, 45256, ‘thumb’,  
‘godjesus\_thumb.jpg’, 81, 2, 100)

Still NOTHING happens in the portfolios-table…

I’ve been following the tutorial @  
[http://www.clarkware.com/cgi/blosxom/2007/02/24](http://www.clarkware.com/cgi/blosxom/2007/02/24)

---

<div class="post-metadata">

**Author:** ![kaizerkaizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@kaizerkaizer](https://www.ruby-forum.com/u/kaizerkaizer)\
**Post date:** [February 5, 2008, 10:28pm UTC](https://www.ruby-forum.com/t/duplicate-entry-1-for-key-1/128180/2 "2008-02-05T22:28:59Z")

</div>

You’ve set parent\_id to be a primary key.

On Feb 6, 2008 2:17 AM, Dag S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
wrote:

> ## I’ve been following the tutorial @ [http://www.clarkware.com/cgi/blosxom/2007/02/24](http://www.clarkware.com/cgi/blosxom/2007/02/24)
> 
> Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> 
> >

–  
Ryan B.

> **[frozenplague.net](http://www.frozenplague.net)**
>
> This domain may be for sale!

Feel free to add me to MSN and/or GTalk as this email.

---

<div class="post-metadata">

**Author:** ![kaizerkaizer](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/45deac/32.png) [@kaizerkaizer](https://www.ruby-forum.com/u/kaizerkaizer)\
**Post date:** [February 6, 2008, 2:50pm UTC](https://www.ruby-forum.com/t/duplicate-entry-1-for-key-1/128180/3 "2008-02-06T14:50:10Z")

</div>

Ryan B. wrote:

> You’ve set parent\_id to be a primary key.
> 
> On Feb 6, 2008 2:17 AM, Dag S. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
> wrote:
> 
> > ## I’ve been following the tutorial @ [http://www.clarkware.com/cgi/blosxom/2007/02/24](http://www.clarkware.com/cgi/blosxom/2007/02/24)
> > 
> > Posted via [http://www.ruby-forum.com/](http://www.ruby-forum.com/).
> > 
> > >
> 
> –  
> Ryan B.  
> [http://www.frozenplague.net](http://www.frozenplague.net)  
> Feel free to add me to MSN and/or GTalk as this email.

Ah, thanks. That was an easy one for you!  
;D
