On 10/3/06, David Lelong
<rails-mailing-list-ARtvInVfO7ksV2N9l4h3zg@public.gmane.org>
wrote:>
>
> Hi,
>
> I have a model with the following validation:
>
> validates_uniqueness_of :contact_id, :scope => :list_id
>
> The validation works correctly and prevents duplicate records being
> created that contain the same contact_id and list_id.
>
> However, I can''t get the error message to appear on the submission
form.
>
> I have:
>
> <%= error_messages_for ''contact_list'' %>
>
enclosed within the form, but it''s only displaying flash[:notice]
> messages from the controller.
>
> How do I get to display error messages from the model?
For this to work you need to have an instance variable called @contact_list
So if it''s a user object that you''ve got errors on, and
you''ve stuffed it
into an @user instance variable, you would need to use
<%= error_messages_for ''user'' -%>
--~--~---------~--~----~------------~-------~--~----~
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
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk
-~----------~----~----~----~------~----~------~--~---