Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我有一些数字,例如 75.00,我正在尝试将其转换为单词,因为我使用了 humanize
75.humanize
但它不断抛出错误“未定义的方法人性化错误 75:Float”
确保您已安装humanizegem
humanize
现在您可以将数字转换为单词
2.humanize #=> "two" 4.humanize #=> "four" 8.humanize #=> "eight" 75.humanize #=> "seventy-five" 75.0.humanize #=> "seventy-five point zero" 75.00.humanize #=> "seventy-five point zero"
注意: Railshumanize在字符串类中也有一个方法,它的工作方式不同