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 [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/rubyonrails-core?hl=en
-~----------~----~----~----~------~----~------~--~---