Appendix D. A Catalog of Helper Methods

Everyone who has used Rails for a while has their own set of “commonly used” helper methods. Many times, though, those commonly used sets are different. Some people use FormHelper for all of their forms, while others prefer FormTagHelper. Some people use AssetTagHelper, while others handcode links to static resources like stylesheets and images.

Rather than provide a comprehensive reference to these methods—the API documentation does that—this appendix provides a catalog you can browse to decide which methods might actually prove useful to your own needs. Much of the difficulty in using helpers is in finding them before you reinvent the wheel yourself.

All of these classes are subclasses of ActionView::Helpers.

Note

The easiest place to find API documentation, in a friendlier form than usual, is at http://rails-doc.org/. The search boxes give you choices as you type, and the explanations are presented in smaller pieces. You can also find the documentation at http://www.railsbrain.com/ and http://www.gotapi.com/rubyrails. They’re all a little different, but hopefully one of them will prove comfortable for you.

Calling Helper Methods

Every helper method has its own set of parameters, and often it’s not clear from the documentation which parameters it will accept. How do you interpret the following?

label(object_name, method, text = nil, options = {})

The first few parameters at least take simple values. The object_name parameter will take ...

Get Learning Rails now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.