Skip to content

Instantly share code, notes, and snippets.

@1dolinski
Created April 11, 2013 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save 1dolinski/5362279 to your computer and use it in GitHub Desktop.
Save 1dolinski/5362279 to your computer and use it in GitHub Desktop.
<%= form_tag("/search", :method => "get") do %>
<%= label_tag(:q, "Search for:") %>
<%= text_field_tag(:q) %>
<%= submit_tag("Search") %>
<% end %>
This will generate the following HTML:
<form accept-charset="UTF-8" action="/search" method="get">
<label for="q">Search for:</label>
<input id="q" name="q" type="text" />
<input name="commit" type="submit" value="Search" />
</form>
@1dolinski
Copy link
Author

for #=> text_field_tag(:q)

Why are we passing a :q? Why not "q" .. the user puts in :q and the code runs :q.to_s ... what is the benefit of this?

@1dolinski
Copy link
Author

Apparently the reason is that strings are garbage collecting while symbols are not

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment