# Output validations errors form causing type error?

**URL:** <https://www.ruby-forum.com/t/output-validations-errors-form-causing-type-error/176887>\
**Category:** Rails\
**Created:** [October 7, 2009, 4:32pm UTC](https://www.ruby-forum.com/t/output-validations-errors-form-causing-type-error/176887 "2009-10-07T16:32:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 7, 2009, 4:32pm UTC](https://www.ruby-forum.com/t/output-validations-errors-form-causing-type-error/176887/1 "2009-10-07T16:32:10Z")

</div>

Hi,

I was wondering if it is possible to output validation errors in a  
nested form? I suppose this should be possible, but I am experiencing  
an error message that I can’t track down.

The error I get is the following :  
TypeError in Store/orders#create  
Showing app/views/store/orders/new.html.erb where line #45 raised:  
can’t convert Array into String

This is ocurring in the following view code:  
\<% form\_for :order, @order, :url =\> store\_orders\_url, :html =\> {:class  
=\> “myform”} do |order\_form| %\>  
\<%= order\_form.error\_messages %\>

I can’t understand why this would be ocurring, because I was able to  
inspect the errors object for @order in the log, and it seems normal  
to me, I don’t know why it cause errors in outputting errors to the  
view for this object. Here is the output of the inspect method:

errors object #\<ActiveRecord::Errors:0x105c343c0 @errors=  
{“customer\_billing\_state”=\>[“must be present”], “card\_number”=\>[[“is  
not a valid credit card number”]], “customer\_select\_state”=\>["^State/  
Province must be a U.S. state selected from the drop down list for  
customers in United States"], “card\_verifiation”=\>[[“is required”]]},  
@base=#\<Order id: nil, created\_at: nil, updated\_at: nil, customer\_id:  
nil, gst: #BigDecimal:105d342c0,‘0.0’,9(18), qst: #\<BigDecimal:  
105d33ed8,‘0.0’,9(18)\>, shipping\_ca: #\<BigDecimal:105d33ac8,‘0.0’,9(18)

> , shipping\_us: #BigDecimal:105bfb840,‘0.7E1’,9(18), currency:  
> “USD”, status: nil, comments: nil, customer\_ip: “127.0.0.1”,  
> payment\_method: “Credit Card”, downloaded: nil, express\_token: nil,  
> express\_payer\_id: nil, card\_type: “visa”, card\_expires\_on:  
> “2009-10-01”\>\>

If anyone has any idea where I can start looking to debug this error,  
I would appreciated it very much.

Thanks,  
Sean

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [October 7, 2009, 5:26pm UTC](https://www.ruby-forum.com/t/output-validations-errors-form-causing-type-error/176887/2 "2009-10-07T17:26:02Z")

</div>

Please ignore my post, I discovered what the problem was. I had been  
manually adding errors to the order object from the validations of  
another model (active merchant’s credit card class), and my mistake  
was that I had added the errors directly, but the errors for each  
attribute are an array of errors, so instead I just need to loop  
through them and they add them to my order object using the errors.add  
method. Just in case anyone else runs into a similar problem.

sean

On Oct 7, 10:30 am, “removed\_email\_address@domain.invalid” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)
