From the course: Ruby on Rails 5 Essential Training

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Number helpers

Number helpers - Ruby on Rails Tutorial

From the course: Ruby on Rails 5 Essential Training

Start my 1-month free trial

Number helpers

- [Voiceover] In this movie, we'll take a look at the helpers that Rails provides to help us to output numbers. There're seven main helpers to help you format numbers for display. And I've arranged them in roughly the order that I think you're going to use them. There's number_to_currency, number_to_percentage, number_with_precision, number_with_delimiter, number_to_human, number_to_human_size, number_to_phone. And in number_with_precision and number_with_delimiter, which are the two that don't follow the pattern of having number_to, they start with number_with. They have aliases as well. Which is number_to_rounded and number_to_delimited. That's to try and bring them into line. Number_with is the older names that have been there since the beginning of Rails. The newer names are aliases and you can feel free to use either one of them. All of these helper methods take a number as their first argument and then a hash of options as their second argument. You only need to provide the hash…

Contents