I have the following:
class Profile < AR:B
belongs_to :profile_detail
accepts_nested_attributes_for :profile_detail
end
The way I have my views structured means that most of the time a
user will be editing their Profile and the ProfileDetail
information together, in fact in this case I extracted
ProfileDetail from Profile.
The current behavior of the error_message helper is to prepend
the association name to any errors that occur when the nested
attributes are validated. However, in my case all of the attributes
are unique so there's no benefit to having the association name
prepended when displaying the errors and it makes the validation
errors look a bit weird.
This is primarily a view related change, just like we can
specify the object_name for our error_messages I think it should be
possible to set the validation message prefix for autosaved
associations, perhaps using a mapping:
<%= f.error_messages :error_prefix => {
:funky_association_with_massive_name => 'cake' } %>
or by flattening them all:
<%= f.error_messages :flatten_errors_on_associations =>
true %>
I'd be happy to attempt to create a patch for this as I think it
serves a genuine purpose. I await your feedback.