I have errors in a model that are showing up in the view when accessed with @model.errors. However, they do not show up if I try to do
<%form_for @applicant do |f|%>
<%=f.error_messages%>
This is zero, freakily: <%=f.error_messages.length%>
But this is not: <%[email protected]%>
however, the errors are present if I do
@applicant.errors.each
Any suggestions as to where I should look to resolve this? It's absolutely strange...
The form is working perfectly otherwise.
Edit: Thanks to ScottD's answer I figured out what was happening. I had simplified the question here on SO, but that was the problem. I was really doing this:
<%form_for @applicant.thinger do |f|%>
and therein lies the problem. The error_messages_for method that the form_helper calls needs the thing to be one level deep (meaning an instance variable like @applicant, which it then translates to :applicant, and never like @applicant.status). Thanks!