Forum: Ruby on Rails validation error reporting on child object

Announcement (2017-05-07): is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see and for other Rails- und Ruby-related community platforms.
Ben M. (Guest)
on 2006-02-14 02:58
(Received via mailing list)
How does one deal with validation error messages on child objects of the
main model object
behind a page?

I have the basic blog w/ comments page (only my "entry" is a
"proposal"). I have the
comments saving just fine, but I wanted to show an error if the user
hits the submit
button without typing anything in the comment.

I added "validates_presence_of :comment_text" in my Comment AR class,
and it appears that
the empty comment is no longer being inserted into the db. However, I
can't figure out how
to display the error message on the comment object (1 to M child of
proposal) in the page.

I put an "else" on the call to save the comment in my add_comment action
and that is getting called, but
I can't figure out where the error message going. Looked at
in the view, I don't see an error message.


This topic is locked and can not be replied to.