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

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

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs