Issues with displaying validation messages with Nested Forms (Rails 2.3)
I have a nested form, and for the most part it is working great. The only issue that I have is in displaying validiation errors.
Consider the following object relationship: a Project has_many :tasks, a Task has_many :assignments
if a validation 开发者_开发百科error occurs on an assignment, with <%=project_form.error_messages %>
It displays Task Assignment Due Date is invalid I would rather it just read Due Date is invalid or Jon's Math Homework Due Date is invalid.
Does this support exist? Do I need to roll my own? Anyone have any ideas?
Thanks!
Jonathan
In my application those errors didn't has "Task Assignment" part. I don't remember that I had changed something somewhere. You can try writing your own method to display errors. You can get to them using:
@project.errors
or using form builder:
project_form.object.errors
Firstly try to just inspect them:
# in view
<%= @project.errors.inspect %>
It will allow you to take a look on it's structure.
精彩评论