Skip to content

Commit

Permalink
change geocoding address for Governor offices to city_state_zip
Browse files Browse the repository at this point in the history
  • Loading branch information
msimonborg committed Jun 20, 2017
1 parent 2129f04 commit 3589258
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion app/models/office_location.rb
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class OfficeLocation < ApplicationRecord
has_one :v_card, dependent: :destroy
has_many :issues

geocoded_by :full_address
geocoded_by :geocoder_address

after_validation :geocode, if: :needs_geocoding?

Expand Down Expand Up @@ -84,6 +84,14 @@ def city_state_zip
[city, state, zip].join(' ')
end

def geocoder_address
if rep.is_a?(Governor)
city_state_zip
else
full_address
end
end

def calculate_distance(coordinates)
return if needs_geocoding?
@distance = Geocoder::Calculations.distance_between(coordinates, [latitude, longitude]).round(1)
Expand Down

0 comments on commit 3589258

Please sign in to comment.