Lighthouse has a new layout. Prefer the old one? Return to the old layout, and switch back any time from the link at the top of each page.

This project is archived and is in readonly mode.

[PATCH] full_messages generates lame messages for associations

#6745

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.

Reported by Josh Sharpe · April 26th, 2011 @ 04:28 AM

State: new
Milestone: none
Assigned to: nobody
Importance: none

Activity

  1. Josh Sharpe
    Josh Sharpe

    okay, seriously, lighthouse won't accept my patch. no error, nothing:

    http://pastebin.com/qVeRBp3R

    April 26th, 2011 @ 04:31 AM

  2. Josh Sharpe
    Josh Sharpe

    okay... fail. maybe this will work

    April 26th, 2011 @ 04:33 AM