Take the 2-minute tour ×  I have a partial that I use to show
errors from an object onto a form.  <% if object.errors.any? %>
<div id="error_explanation">             <h2>Oops, looks like
<%= pluralize(object.errors.count, "error") %>             <br
/>                 <% object.errors.each do |key, msg| %>
<li><%=key%><%= msg %></li>                 <% end %>     <% end
%>  It works great for 1 model.  However I can't figure out how
to make it work for a form that has two models.  Any ideas? I
don't want to use the plugin I would like to have more control.
share|improve this question add comment  1 Answer  up vote 2
down vote accepted  Just output the partial for each model in
the form view with 2 models and pass actual model instances into
this partial as local variable:  <%= render :partial =>
'name_of_partial_to_show_model_errors', :locals => {:object =>
@model1} %> <%= render :partial =>
'name_of_partial_to_show_model_errors', :locals => {:object =>
@model2} %> share|improve