Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Updating index view for searching by state

  • Loading branch information...
commit f63922e48a90d0e30196f05f1073f379a07b9a3d 1 parent 5077116
@pat pat authored
Showing with 4 additions and 2 deletions.
  1. +4 −2 app/views/contacts/index.html.erb
View
6 app/views/contacts/index.html.erb
@@ -2,7 +2,9 @@
<% form_tag "", :method => :get do -%>
<p>
- <%= text_field_tag :search %>
+ <%= text_field_tag :search, params[:search] %>
+ <%= select_tag :state_id,
+ options_from_collection_for_select(@states, "id", "name", params[:state_id].to_i) %>
<%= submit_tag "Search" %>
</p>
<% end -%>
@@ -25,7 +27,7 @@
<td><%= h contact.last_name %></td>
<td><%= h contact.street_address %></td>
<td><%= h contact.city %></td>
- <td><%= h contact.state %></td>
+ <td><%= h contact.state.name %></td>
<td><%= h contact.country %></td>
<td><%= h contact.postal_code %></td>
<td><%= link_to 'Show', contact %></td>
Please sign in to comment.
Something went wrong with that request. Please try again.