Introduction
Ruby programmers created the web application development framework known as Rails. Rails are part of Ruby. It is intended to make web application programming simpler by assuming that all developers have the prerequisites for getting started. Compared to many other languages and frameworks, Ruby on rails enables you to write less code while doing more. Additionally, seasoned Ruby on Rails developers claims that it increases the enjoyment of creating web applications.

Before moving forward, there are a few misconceptions that need to be cleared up. Form objects are frequently used to simplify the controller and the model, which isn't wrong but doesn't do them justice given the crucial role they play.
Reduced decoupling between the controller, model (including multiple models), and view template results from moving responsibilities to the form object.
There are instances where creating a form that can handle numerous items (like model objects) at once is necessary to create a decent user experience. Users only prefer to click the submit button once, therefore you had better be able to provide them with the straightforward interface they want.
Forms are a crucial user input interface in online applications. However, due to the necessity to handle form control names and their multiple characteristics, form markup may easily become onerous to develop and maintain. Ruby on Rails eliminates this complexity by offering view helpers that provide form markup. Developers must first be aware of the variations between the assistance methods because these helpers have various use cases.
Dealing with basic forms
Form with is the primary form helper. This way of calling it creates a form tag that when filled out will POST to the current page. For instance, the resulting HTML will seem as follows, assuming the current page is the home page:
<form accept-charset="UTF-8" action="/" method="post">
<input name="authenticity_token" type="hidden" value="J7CBxfHalt49OSHp27hblqK20c9PgwJ108nDHX/8Cts=" />
Form contents
</form>
You'll see that there is an input element with a hidden type in the HTML. This input is crucial because, without it, non-GET forms cannot be submitted correctly. Cross-site request forgery protection is a security feature of Ruby on Rails, and form helpers create the hidden input element with the name authenticity token for each non-GET form (provided that this security feature is enabled)
Helpers for generating form elements
Numerous assistance methods are available in the form builder object returned by form for creating form components including text fields, checkboxes, and radio buttons. The name of the input is always the first parameter for these methods. The name will be sent to the params in the controller along with the form data when it is submitted, along with the value that the user-supplied for that field. You might, for instance, use params[: query] in the controller to retrieve the value of the field if the form has <%= form.text_field :query %>. Ruby on Rails has naming standards for inputs that enable the submission of parameters with non-scalar values, such as arrays or hashes, which will also be used.
Checkboxes

Checkboxes are form controls that allow the user to enable or disable a set of choices.
<input type="checkbox" id="coding_ninjas" name="coding_ninjas" value="1" />
<label for="pet_dog">I own a course</label>
<input type="checkbox" id="coding_ninjast" name="coding_ninjas" value="1" />
<label for="pet_cat">I own a course</label>
The name of the input is the first parameter to check box. The input value is the second argument. When the checkbox is selected, this value will be present in the parameters as well as the form's data.
Radio Buttons

Although they resemble checkboxes, radio buttons are controls that specify a group of options that are mutually exclusive (the user can only select one):
<input type="radio" id="DSA" name="course1" value="subject1" />
<label for="age_child">I am course DSA</label>
<input type="radio" id="SQL" name="course2" value="subject2" />
<label for="age_adult">I am course SQL</label>
The input value is the second parameter for the radio button, just like it is for the check box. The user can only choose one of these two radio buttons because they both have the same name (age), and params[: age] will either include "child" or "adult."




