Permalink
Browse files

Fixing index view for search

  • Loading branch information...
1 parent 2ad0111 commit 205069473294da6879de7dc0f0291b17dcda3efd @pat pat committed Sep 29, 2008
Showing with 38 additions and 28 deletions.
  1. +38 −28 app/views/contacts/index.html.erb
View
66 app/views/contacts/index.html.erb
@@ -1,34 +1,44 @@
-<h1>Listing contacts</h1>
+<h1>Search Contacts</h1>
-<table>
- <tr>
- <th>First name</th>
- <th>Last name</th>
- <th>Street address</th>
- <th>City</th>
- <th>State</th>
- <th>Country</th>
- <th>Postal code</th>
- </tr>
+<% form_tag "", :method => :get do -%>
+ <p>
+ <%= text_field_tag :search %>
+ <%= submit_tag "Search" %>
+ </p>
+<% end -%>
-<% for contact in @contacts %>
- <tr>
- <td><%=h contact.first_name %></td>
- <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.country %></td>
- <td><%=h contact.postal_code %></td>
- <td><%= link_to 'Show', contact %></td>
- <td><%= link_to 'Edit', edit_contact_path(contact) %></td>
- <td><%= link_to 'Destroy', contact, :confirm => 'Are you sure?', :method => :delete %></td>
- </tr>
-<% end %>
-</table>
+<% unless @contacts.empty? %>
+ <table>
+ <tr>
+ <th>First name</th>
+ <th>Last name</th>
+ <th>Street address</th>
+ <th>City</th>
+ <th>State</th>
+ <th>Country</th>
+ <th>Postal code</th>
+ </tr>
-<br />
+ <% for contact in @contacts %>
+ <tr>
+ <td><%= h contact.first_name %></td>
+ <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.country %></td>
+ <td><%= h contact.postal_code %></td>
+ <td><%= link_to 'Show', contact %></td>
+ <td><%= link_to 'Edit', edit_contact_path(contact) %></td>
+ <td><%= link_to 'Destroy', contact, :confirm => 'Are you sure?', :method => :delete %></td>
+ </tr>
+ <% end %>
+ </table>
+
+ <br />
-<%= will_paginate @contacts %>
+ <%= will_paginate @contacts %>
+<% end %>
+<br />
<%= link_to 'New contact', new_contact_path %>

0 comments on commit 2050694

Please sign in to comment.