Commit 66ea71b
Changed files (2)
app
models
views
gyms
app/models/location.rb
@@ -10,6 +10,10 @@ class Location < ActiveRecord::Base
latitude == 0.0 && longitude == 0.0 ? [] : [latitude, longitude]
end
+ def url
+ "https://maps.google.com/?q=#{latitude},#{longitude}"
+ end
+
class << self
def build_from_ip(ip)
result = search(ip)
app/views/gyms/index.html.erb
@@ -10,7 +10,7 @@
<tr>
<td><%= gym.name %></td>
<td><%= gym.location.address %>, <%= gym.location.city %>, <%= gym.location.region %>, <%= gym.location.country %></td>
- <td><a href="https://maps.google.com/?q=<%= gym.location.latitude %>,<%= gym.location.longitude %>" target="_blank"><%= t('.view_map') %></a></td>
+ <td><%= link_to t('.view_map'), gym.location.url %></td>
</tr>
<% end %>
</table>