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
<h1>Add new article</h1>
<% form_tag :action => 'create' do %>
<p><label>Title</label>:
<%= text_field 'article', 'title' %></p>
<p><label>Body</label>:
<br />
<%= text_area 'article', 'body' %></p>
<p><label>Date</label>:
<%= text_field 'article', 'date' %></p>
<p><label>Tag</label>:
<%= text_field 'article', 'tag' %></p>
<%= submit_tag "Create" %>
<% end %>
<%= link_to 'Back', {:action => 'list'} %>
------
please help :(
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby
on Rails: Talk" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---