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: The first argument,/search, is the action. The second sets the HTTP method. Search forms should usegetso the query is a URL, not a POST body.label_tag: Creates an HTML<label>.text_field_tag: Creates<input type="text">.submit_tag: Creates<input type="submit">.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents