How do I render form_for error messages outside of the form_for div?
This is what I have now:
<div id="editUser_form", class="round">
<h1>Edit user</h1>
<%= form_for @user, :html => { :multipart => true } do |f| %>
<%= render 'shared/error_messages', :object => f.object %>
...
<% end %>
</div>
However, I want it to look more like this:
<%= render 'shared/error_messages', :object => f.object %>
<div id="editUser_form", class="round">
<h1>Edit user</h1>
<%= form_for @user, :html => { :multipart => true } do |f| %>
...
<% end %>
</div>
The code above gives me an error because :object => f.object must be part of the form. Is there a way to pass the f.object to the shared/error_messages?
Thanks!
The object is @user, so you can do this:
Anywhere that @user is defined, as long as the partial doesn’t rely on anything else in the form object.