for_for and validates_uniqueness_of problems

I have the following:

class Dummy < ActiveRecord::Base
     validates_uniqueness_of :dummy
end

def update
      @d = Dummy.new(params[:dummy])
end

<% form_for :dummy, @dummy, :url => {:action => "update" } do |form| %>
<%= error_messages_for :dummy %>

<%= form.text_field :dummy %>
<%= form.text_field :dummy2 %>
<%= submit_tag %>
<% end %>

My purpose is to display a error_message "No duplicate entry allowed" when someone tries to enter a dummy which is always in the database. How to do this!

validates_uniqueness_of works as I'am not able to insert to idendical entries to the database - but the only thing I get on my screen is:

#ActiveRecord::RecordInvalid in DummyController#update
#Validation failed: Dummy has already been taken
#RAILS_ROOT: script/../config/..
#Application Trace | Framework Trace | Full Trace

.

Isn't "error_messages_for" the way to display individual error messages?

Thanx

Jochen,

You might get better response by posting to the general Rails mailing list (http://groups.google.com/group/rubyonrails-talk). This list is for topics regarding the development of Rails itself.

You probably get the error page because you use save! (with exclamation mark) instead of just save. save! raises an error if the validations fail.

Cheers,
//jarkko