Good notes posted by patrickberkeley
RSS feed
6 thanks
Pluralize Without Count
Helper method that returns the word without the count.
application_helper.rb
def pluralize_without_count(count, noun, text = nil) if count != 0 count == 1 ? "#{noun}#{text}" : "#{noun.pluralize}#{text}" end end
Example usage:
_form.html.erb
<%= pluralize_without_count(item.categories.count, 'Category', ':') %>

4 thanks
Hour with/without preceding zero
One gotcha is the difference between the hour in 12 hour time with and without a preceding zero. In some fonts they look the same.
With preceding zero (capital I)
Time.now.strftime("%I:%M") # => 05:21
Without preceding zero (lowercase L)
Time.now.strftime("%l:%M") # => 5:21