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.

There was a problem

You must be a member of this account.

This project is archived and is in readonly mode.

Humanize Inflections

#535

As discussed and described in the old Rails Trac already, it would be good to be able to specify custom inflection rules and strings for #humanize:

Inflector.inflections do |inflect|
  inflect.human /_cnt$/i, '\1_count'
  inflect.human "legacy_col_person_name", "Name"
  inflect.human "strt_dt" => "Start date",
                "upd_dt"  => "Updated date"
end

"the_cnt".humanize #=> "The count"
"upd_dt".humanize  #=> "Updated date"

I hope this will be accepted this time as it is (at least for me) an important feature and quite easy to implement.

Find attached a patch against edge, including tests.

Reported by Pascal Ehlert · July 2nd, 2008 @ 08:49 AM

State: resolved
Milestone: 2.x
Assigned to: nobody
Importance: none

Activity

  1. Pascal Ehlert
    Pascal Ehlert

    Sorry, the above example is slightly incorrect, I have taken out possibility of Hash attributes to retain API consistency, although I liked it.

    Depends on you whether we can take it in or not.

    July 2nd, 2008 @ 08:51 AM

  2. Repository
    Repository

    (from [4f75840d72b96fff34d65b59480da7d6c7494120]) Add Inflection rules for String#humanize. [#535 state:resolved] [dcmanges]

    Signed-off-by: Pratik Naik

    http://github.com/rails/rails/co...

    July 2nd, 2008 @ 01:30 PM

  3. Pratik
    Pratik
    • State changed from new to resolved

    July 2nd, 2008 @ 01:30 PM