because you are passing the variable object to your partial, but in partial you are trying to use a variable called @user . Change each instance of @user in partial to object , and it will work fine.
1:<% if object.errors.any? %> 2:<div id="error_explanation"> 3:<h2><%= pluralize(object.errors.count, "error") %> 4:prohibited this <%= object.class.to_s.underscore.humanize.downcase %>
UPDATE: To clarify, the answers above suggest there is an error setting the @user variable, but this is normal. When you say :object => f.object in a render call, you tell render to take the object that this form is based on and send it partial β with the variable name object .
The whole point of refactoring an error code into a common partial code is that it will be used by several forms for different models. In the partial part, you cannot say @user , because you will use the same part for all your other models. Therefore, if the code is partially modified to use the more common variable name, object .
source share