Generating Forms

HTML provides a number of elements, attributes, and attribute values that control how input is gathered. You certainly could hand-code your form directly into the template, but there really is no need to do that.

In this section, we will cover a number of helpers that Rails provides that assist with this process. In Using Helpers, we’ll show you how you can create your own helpers.

HTML provides a number of ways to collect data in forms. A few of the more common means are shown in the following screenshot. Note that the form itself is not representative of any sort of typical use; in general, you’ll use only a subset of these methods to collect data.

Let’s look at the template that was used to produce that form:

Get Agile Web Development with Rails 6 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.