From the course: Ruby on Rails 6: Controllers and Views

Unlock the full course today

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

Text helpers

Text helpers - Ruby on Rails Tutorial

From the course: Ruby on Rails 6: Controllers and Views

Start my 1-month free trial

Text helpers

- [Instructor] One of the great aspects of Ruby on Rails is the wide variety of helper methods it has that help you to perform common web developer tasks. In this chapter, we're going to be looking at some of the most common of those starting with text helpers. We're going to be looking at four to begin with. Word wrap, simple format, truncate and pluralize. Word wrap does what it says. You have a bit of text, it's too long, you want to wrap it to a set length where you can tell it then to break that up into links of lines no longer than whatever you specify. It's 80 by default. And it's smart about not breaking a word in half. It tries to break on the white space. Here's an important note though, notice that it puts backslash in for all of those line breaks. If you're out putting this text HTML, HTML will not respect these line breaks unless they're inside pretax. Otherwise, it will ignore them. If you want…

Contents