# Virtual Atrributes + error\_message\_for ploblem?

**URL:** <https://www.ruby-forum.com/t/virtual-atrributes-error-message-for-ploblem/157551>\
**Category:** Rails\
**Created:** [January 13, 2009, 2:06am UTC](https://www.ruby-forum.com/t/virtual-atrributes-error-message-for-ploblem/157551 "2009-01-13T02:06:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [January 13, 2009, 2:06am UTC](https://www.ruby-forum.com/t/virtual-atrributes-error-message-for-ploblem/157551/1 "2009-01-13T02:06:44Z")

</div>

Hello there,

I used a screencast ( [#16 Virtual Attributes - RailsCasts](http://railscasts.com/episodes/16) ) to make a  
Nested form.  
The problem is that when I will show the error\_messages\_for I will just  
get a single line of error for each element that is related with the  
main element.

Codes are here:

[http://pastie.org/359215](http://pastie.org/359215) - Invoice.rb  
[http://pastie.org/359217](http://pastie.org/359217) - InvoiceItem.rb  
[http://pastie.org/359218](http://pastie.org/359218) - Controller.rb

Error looks like this:

6 errors prohibited this Invoice from being saved  
There were problems with the following fields:  
\* Invoice item is invalid  
\* Invoice item is invalid  
\* Invoice item is invalid  
\* Invoice item is invalid  
\* Invoice item is invalid  
\* Invoice item is invalid

What I was expecting to receive was some thing like:

6 errors prohibited this Invoice from being saved  
There were problems with the following fields:  
\* Invoice item name can’t be black  
\* Invoice item price can’t be black  
\* Invoice item name is too short  
\* Invoice item name can’t be black  
\* Invoice item name is too long  
\* Invoice item price can’t be black

Anyone has an idea how to fix it?

Tks,

David S.

---

<div class="post-metadata">

**Author:** ![davidstokar](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/d/4da419/32.png) [@davidstokar](https://www.ruby-forum.com/u/davidstokar)\
**Post date:** [January 14, 2009, 3:23am UTC](https://www.ruby-forum.com/t/virtual-atrributes-error-message-for-ploblem/157551/2 "2009-01-14T03:23:36Z")

</div>

Uhm… anyone?  
The problem is not solved yet!

tks,

David S.
