Commit 41de54c
Changed files (3)
app
models
views
app/models/gym.rb
@@ -68,6 +68,10 @@ class Gym < ActiveRecord::Base
end
end
+ def map_url
+ "https://maps.google.com/maps/place/#{name}/@#{location.latitude},#{location.longitude},12z"
+ end
+
def duplicate?(distance: 0.1)
return true if yelp_id.present? && Gym.where.not(id: id).exists?(yelp_id: yelp_id)
Gym.
app/views/gyms/_index.html.erb
@@ -11,7 +11,7 @@
<td><%= gym.new_record? ? gym.name : link_to(gym.name, gym_path(gym)) %></td>
<td>
<%= gym.full_address %>
- <%= link_to gym.location.try(:url) do %>
+ <%= link_to gym.map_url do %>
<i class="fa fa-map-marker" aria-hidden="true"></i>
<% end %>
</td>
app/views/gyms/show.html.erb
@@ -3,7 +3,7 @@
<h1><%= @gym.name %></h1>
<p>
<%= @gym.full_address %>
- <%= link_to @gym.location.try(:url) do %>
+ <%= link_to @gym.map_url do %>
<i class="fa fa-map-marker" aria-hidden="true"></i>
<% end %>
</p>