# Mysql::Error: Duplicate entry

**URL:** <https://www.ruby-forum.com/t/mysql-duplicate-entry/158867>\
**Category:** Rails\
**Created:** [January 28, 2009, 10:14pm UTC](https://www.ruby-forum.com/t/mysql-duplicate-entry/158867 "2009-01-28T22:14:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruby\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ruby\_ruby](https://www.ruby-forum.com/u/ruby_ruby)\
**Post date:** [January 28, 2009, 10:14pm UTC](https://www.ruby-forum.com/t/mysql-duplicate-entry/158867/1 "2009-01-28T22:14:32Z")

</div>

hello , I am designing a project for a news website and I am new to ROR  
I am facing a problem with the add news function

this is the error

Mysql::Error: Duplicate entry ‘’ for key 1: INSERT INTO `articals`  
(`body`, `title`, `date`, `tag`) VALUES(‘nnn’, ‘llllhhh’, ‘2008-03-02’,  
‘tttt’)

* * *

this is my code

class ArticleController \< ApplicationController

def new

@article = Article.new  
@article.date = Date.today  
end

def create  
@article = Article.new(params[:article])  
if @article.save  
redirect\_to :action =\> ‘list’  
else  
render :action =\> ‘new’  
end  
end

* * *

add.rhtml in views

# Add new article
\<% form\_tag :action =\> 'create' do %\>

Title: \<%= text\_field 'article', 'title' %\>

Body:  
\<%= text\_area 'article', 'body' %\>

Date: \<%= text\_field 'article', 'date' %\>

Tag: \<%= text\_field 'article', 'tag' %\>

## \<%= submit\_tag “Create” %\> \<% end %\> \<%= link\_to ‘Back’, {:action =\> ‘list’} %\>

please help ☹

---

<div class="post-metadata">

**Author:** ![ruby\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ruby\_ruby](https://www.ruby-forum.com/u/ruby_ruby)\
**Post date:** [January 29, 2009, 1:44am UTC](https://www.ruby-forum.com/t/mysql-duplicate-entry/158867/2 "2009-01-29T01:44:22Z")

</div>

On 28 Jan 2009, at 21:14, Rt Rr wrote:

> ‘2008-03-02’,  
> ‘tttt’)

sounds like you’ve got a unique index somewhere.

Fred

---

<div class="post-metadata">

**Author:** ![ruby\_ruby](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/r/cab0a1/32.png) [@ruby\_ruby](https://www.ruby-forum.com/u/ruby_ruby)\
**Post date:** [January 29, 2009, 3:47pm UTC](https://www.ruby-forum.com/t/mysql-duplicate-entry/158867/3 "2009-01-29T15:47:07Z")

</div>

Frederick C. wrote:

> On 28 Jan 2009, at 21:14, Rt Rr wrote:
> 
> > ‘2008-03-02’,  
> > ‘tttt’)
> 
> sounds like you’ve got a unique index somewhere.
> 
> Fred

it’s work now 🙂

thx very much Fred
