how can I add another model to ActionView::Base.field_error_proc ?


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 = do |html_tag, instance_tag|   css_class = /^<label/.match(html_tag) ? 'error_label' : 'error_field'   "<span class='#{css_class}'>#{html_tag}</span>" 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.