截断
- truncate("Once upon a time in a world far far away")
- # => "Once upon a time in a world..."
- truncate("Once upon a time in a world far far away", :length => 17)
- # => "Once upon a ti..."
- truncate("Once upon a time in a world far far away", :length => 17, :separator => ' ')
- # => "Once upon a..."
- truncate("And they found that many people were sleeping better.", :length => 25, :omission => '... (continued)')
- # => "And they f... (continued)"
- truncate("<p>Once upon a time in a world far far away</p>")
- # => "<p>Once upon a time in a wo..."
单复数
- pluralize(1, 'person')
- # => 1 person
- pluralize(2, 'person')
- # => 2 people
- pluralize(3, 'person', 'users')
- # => 3 users
- pluralize(0, 'person')
- # => 0 people
一般用于 view 层