Skip to content

Commit

Permalink
when coordinates is null return 0 in distance method
Browse files Browse the repository at this point in the history
  • Loading branch information
xxseason committed Oct 24, 2015
1 parent 56be228 commit 23e996a
Showing 1 changed file with 1 addition and 0 deletions.
1 change: 1 addition & 0 deletions app/models/project.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ class Project < ActiveRecord::Base

def distance(coordinates)
coordinates ||= []
return 0 if coordinates.map(&:to_i) == [0, 0]
num = Geocoder::Calculations.distance_between(coordinates, [lat.to_f, lon.to_f]).round(1)
# "#{num} km"
end
Expand Down

0 comments on commit 23e996a

Please sign in to comment.