# How can I add another model to ActionView::Base.field\_error\_proc?

**URL:** <https://www.ruby-forum.com/t/how-can-i-add-another-model-to-actionview-base-field-error-proc/181598>\
**Category:** Rails\
**Created:** [January 14, 2010, 11:59am UTC](https://www.ruby-forum.com/t/how-can-i-add-another-model-to-actionview-base-field-error-proc/181598 "2010-01-14T11:59:25Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![patrick99e99](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/p/858c86/32.png) [@patrick99e99](https://www.ruby-forum.com/u/patrick99e99)\
**Post date:** [January 14, 2010, 11:59am UTC](https://www.ruby-forum.com/t/how-can-i-add-another-model-to-actionview-base-field-error-proc/181598/1 "2010-01-14T11:59:25Z")

</div>

Hi,

If I have a form that has attributes for two different models-- if I  
do .valid? checks on both instances of the model in the create action  
of the controller, then I effectively generate error messages for both  
models, and I can see them both by doing  
errors\_for :model1\_instance, :model2\_instance.

However, if I style my field\_error\_proc differently by doing something  
like:

ActionView::Base.field\_error\_proc = Proc.new do |html\_tag,  
instance\_tag|  
css\_class = /^\<label/.match(html\_tag) ? ‘error\_label’ :  
‘error\_field’  
“#{html\_tag}”  
end

Then only the fields from the model1\_instance (the instance that the  
form was dedicated to) have this span class added to them.

My question is, how can I tell ActionView::Base to add model2\_instance  
to it’s field\_error\_proc ?

Thank you.

-patrick
