You need to get the contact's errors from the contact. Try this out:

      @request = Request.new(params[:request])
      @request.contacts << contact = Contact.new(params[:contact]
      if @request.save
        # everything's fine
      else
        flash[:error] = @request.errors.full_messages.join(', ') +
contact.errors.full_messages.join(', ')
      end

On Mon, Feb 23, 2009 at 9:28 PM, Sijo Kg
<rails-mailing-l...@andreas-s.net> wrote:
>
> Hi
>    That is correct I get the same result when use
> @request.errors.each{}
>      But my problem is when email and name blank,  I dont get the error
> message flash as
>
> Name should not be blank
> Email should not be blank
>
>   but I get error like
>
>     contacts is invalid
>
>   But if suppose my request model too has a validation like
> validates_presence_of :reason, :message => 'Reason should not be blank'
>
>     I get the whole flash[error] like
>
>   Reason should not be blank
>   contacts is invalid
>
>      Why the individual error messages of contact model not appearing?

--~--~---------~--~----~------------~-------~--~----~
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@googlegroups.com
To unsubscribe from this group, send email to 
rubyonrails-talk+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to