error partial for multiple models Rails 3 -


i have partial use show errors object onto form.

<% if object.errors.any? %>         <div id="error_explanation">             <h2>oops, looks  <%= pluralize(object.errors.count, "error") %>              occured:</h2>             <br />             <ul>                 <% object.errors.each |key, msg| %>                     <li><%=key%><%= msg %></li>                 <% end %>             </ul>         </div>     <% end %> 

it works great 1 model.

however can't figure out how make work form has 2 models.

any ideas? don't want use plugin have more control.

just output partial each model in form view 2 models , pass actual model instances partial 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} %> 

Comments

Popular posts from this blog

c++ - Is it possible to compile a VST on linux? -

java - Output of Eclipse is rubbish -

jquery - Confused with JSON data and normal data in Django ajax request -