Follow Along as I Stumble on the Path to Learning RoR

Posts tagged “helpers

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


Time Zones in Rails 3

I was looking for what options I could use to set the time zone config in application.rb.  The best I could find were these posts in Stack Overflow:

essentially they are (for the biggest US zones):

Pacific Time (US & Canada), Central Time (US & Canada), Eastern Time (US & Canada)

The posts are good to reference nonetheless, as there seems to be a lot of confusion on what the config does (and time helpers).