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

On 28.5.2007, at 12.19, jochen kaechelin wrote:


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

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to rubyonrails-core- [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/ group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---


--
Jarkko Laine
http://jlaine.net
http://dotherightthing.com
http://www.railsecommerce.com
http://odesign.fi


Attachment: smime.p7s
Description: S/MIME cryptographic signature

Reply via email to