This project is archived and is in readonly mode.
[PATCH] full_messages generates lame messages for associations
Reported by Josh Sharpe | April 26th, 2011 @ 04:28 AM
Imagine you're a User and you accepts_nested_attributes for Profile. And your fun developer goes and does something like this:
@u = User.new @u.build_profile @u.save
...and then
<%= @u.errors.full_messages.each{|e|
"<p>#{e}</p>"} %>
... or something like that, which dumps this nonsense to the screen:
Profile first name can't be blank
Profile last name can't be blank
Ahh, omg, what is a Profile first name?? Egad, must. get. rid. of. that.
There's no good reason that I can think of that the class name should be in the error message. Sometimes it makes phonetic sense (like in the test suite), but more often than not it ends up just being confusing for end users. I suggest the error messages in the above case simply be:
First name can't be blank
Last name can't be blank
Note that this has nothing to do with the error's key name, which remains "profile.first_name". Form helpers will continue to wrap labels in an error class.
Comments and changes to this ticket
-
Josh Sharpe April 26th, 2011 @ 04:31 AM
okay, seriously, lighthouse won't accept my patch. no error, nothing:
Create your profile
Help contribute to this project by taking a few moments to create your personal profile. Create your profile »
<h2 style="font-size: 14px">Tickets have moved to Github</h2>
The new ticket tracker is available at <a href="https://github.com/rails/rails/issues">https://github.com/rails/rails/issues</a>