Permalink
Browse files

added distance to search

  • Loading branch information...
1 parent c9bdb9f commit 0b6872c73a0b4704d1d3f061a77d58c0d00491d9 @ebner committed Jan 29, 2012
Showing with 39 additions and 0 deletions.
  1. +39 −0 app/views/items/search.html.erb
@@ -0,0 +1,39 @@
+<div id="text">
+
+<form action='/search'>
+<input name="name" type="text" value="<%= params[:name] %>" />
+<input type='submit' value='Search' />
+</form>
+
+<br />
+
+<% if params[:name] %>
+
+<% if @items.empty? %>
+ <span>Nothing found</span><br/>
+<% else %>
+
+<table>
+ <tr>
+ <th>Name</th>
+ <th>Description</th>
+ <th>Distance (km)</th>
+ <th></th>
+ </tr>
+
+<% @items.each do |item| %>
+ <tr>
+ <td><%= item.name %></td>
+ <td><%= item.description %></td>
+ <% a = GeoKit::LatLng.new(@location.lat, @location.long) %>
+ <% b = GeoKit::LatLng.new(item.user.location.lat, item.user.location.long) %>
+ <th><%= a.distance_to(b, :kms) %></th>
+ <td><%= link_to 'Show', item %></td>
+ </tr>
+<% end %>
+</table>
+
+<% end %>
+<% end %>
+
+</div>

0 comments on commit 0b6872c

Please sign in to comment.