Follow Along as I Stumble on the Path to Learning RoR

Posts tagged “us

Common Formatting Helpers

Adding  a list of some of the Rails formatting helpers I often have to use:

  • Converting a number to a dollar amount -> number_to_currency(field_value)
  • Changing the date to US date format (MM/DD/YYYY) -> field_value.strftime(“%m/%d/%Y”)
  • Converting to a percentage -> number_to_percentage(field_value)

For additional helpers with numbers here’s the link to the Rails API for number helpers


US Date Format

My dates were displaying DD-MM-YYYY, but I wanted to display it MM/DD/YYYY.

Here’s an easy way to do that.

http://www.spritle.com/blogs/?p=174