Creating a search form
suggest changeTo 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 the default helper for creating a form. It’s first parameter,/searchis the action and the second parameter specifies the HTTP method. For search forms, it is important to always use the methodgetlabel_tag: This helper creates an html<label>tag.text_field_tag: This will create an input element with typetextsubmit_tag: This creates an input element with typesubmit
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents