以下の内容はhttps://tbpgr.hatenablog.com/entry/20140302/1393756686より取得しました。


ActiveSupport | String#humanize

概要

String#humanize

詳細

String#humanize について

String#humanize

属性の名前を人が見やすい形式に変換する。
アンダースコアをスペースに変更し、
_idを削除し、
先頭の単語をCapitalizeします。

サンプル

# encoding: utf-8
require 'active_support/core_ext/string/inflections'
require 'tbpgr_utils'

class Hoge
  HIGE = "hige"
end

bulk_puts_eval binding, <<-EOS
'person'.humanize
'PERSON'.humanize
'person_id'.humanize
'person_name'.humanize
EOS

__END__
・下記はTbpgrUtils gemの機能
bulk_puts_eval

https://rubygems.org/gems/tbpgr_utils
https://github.com/tbpgr/tbpgr_utils

出力

'person'.humanize # => "Person"
'PERSON'.humanize # => "Person"
'person_id'.humanize # => "Person"
'person_name'.humanize # => "Person name"



以上の内容はhttps://tbpgr.hatenablog.com/entry/20140302/1393756686より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14