This project is archived and is in readonly mode.

#2120 ✓committed
Justin French

humanize and human_name don't separate words

Reported by Justin French | March 3rd, 2009 @ 07:33 PM | in 2.x

Post.human_name # => "Post" PostComment.human_name # => "Postcomment"

I'd expect:

PostComment.human_name # => "Post Comment"

String#humanize has the same "bug", but #titleize works fine:

"PostComment".humanize # => "Postcomment" # WTF? "PostComment".titleize # => "Post Comment"

String#human_name is using humanize, which seems like it's the right method to use, but it isn't. According to the docs, humanize is expecting a lowercased, underscored string (like a method name), which it does perfectly:

"post_comment".titleize # => "Post Comment"

Since humanize is built to deal with method names, not class names, I think human_name should use titleize instead of humanize, which I'm happy to make a patch for.

Alternatively, humanize could be improved to deal with both class names and method names, which I'm also happy to create a patch for.

Comments and changes to this ticket

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>

Referenced by

Pages