Published On: December 24th, 20092 min read

One of the most important features of Rails is it’s rich helper. Sometimes these are lifesavers because you don’t have to write your own code and very useful if you can use it in a clever way. While developing scrumpad ( scrumpad ) I found many places where texts need to be formatted and Rail’s helper came like a great boon. Let’s share some helpers!

1. auto_link

Suppose your text contains both URL and email. auto_link will convert it to as links.

[sourcecode language=”ruby”] auto_link(“Go to and meet”)[/sourcecode] It will place links automatically at the appropriate places. If you want to make the sites as url but not the mail, you can pass the option too like:[sourcecode language=”ruby”] auto_link(“Go to and meet” , :link=>:urls)

auto_link(“Go to and meet” , :link=>:email_address)


2. cycle

While providing alternate colors for tables for style purpose, we often put logic in the code to determine the even and odd row and places the color alternatively. This can be handled by a nice helper named “cycle”

suppose you have two CSS classes named “even” and “odd”. You can make the alternate rows to alternate colors by:[sourcecode language=”ruby”] <tr class=””


[/sourcecode] 3. word_wrap

Yes! You can guess it by its name. If you want to wrap a long line with (or without) a specified width you just call this helper.

[sourcecode language=”ruby”] word_wrap(“A brown colored fox jumped over the lazy dog”, :line_width=>5)[/sourcecode] 4. truncate

At times we wish to show the users a part of our long text and replace the lest with “…”. Rails make it easy for us as usual.[sourcecode language=”ruby”] truncate(“Scrumpad, an agile project management tools by Code71”, 19)[/sourcecode] The output will be something like “Scrumpad, an agile…”

If you want to provide your text instead of “…” you should write it as:[sourcecode language=”ruby”] truncate(“Scrumpad, an agile project management tools by Code71”, 19, “….(More)”)[/sourcecode] The output will be like “Scrumpad, an agile…(More)”

That’s all for today. I will come back to you guys with more. In the meantime, you can try these out (If you haven’t tried these yet :-) )

Contributor: Fuad Bin Omar, COO, Nascenia

Share it, Choose Your Platform!

More to Explore

The Quest for Knowledge Continues. Fuel Your Curiosity.