Tutorial by Examples

You can create a form using the form_tag helper <%= form_tag do %> Form contents <% end %> This creates the following HTML <form accept-charset="UTF-8" action="/" method="post"> <input name="utf8" type="hidden" value=...
To create a search form, enter the following code <%= form_tag("/search", method: "get") do %> <%= label_tag(:q, "Search for:") %> <%= text_field_tag(:q) %> <%= submit_tag("Search") %> <% end %> form_tag: This is t...
Checkboxes <%= check_box_tag(:pet_dog) %> <%= label_tag(:pet_dog, "I own a dog") %> <%= check_box_tag(:pet_cat) %> <%= label_tag(:pet_cat, "I own a cat") %> This will generate the following html <input id="pet_dog" name="pet_dog&q...
Standard example: @models = Model.all select_tag "models", options_from_collection_for_select(@models, "id", "name"), {} This will generate the following HTML: David The last argument are options, which accepts the following: { multiple: false, disabled: false, ...

Page 1 of 1