Skip to content

Commit a1451e6

Browse files
committed
Allow nil lat and long for space
1 parent 2e7aaf9 commit a1451e6

File tree

1 file changed

+10
-2
lines changed
  • app/models/better_together/geography

1 file changed

+10
-2
lines changed

app/models/better_together/geography/space.rb

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ class Space < ApplicationRecord
1313
has_many :geospatial_spaces
1414

1515
validates :elevation, numericality: true, allow_nil: true
16-
validates :latitude, numericality: { greater_than_or_equal_to: -90, less_than_or_equal_to: 90 }
17-
validates :longitude, numericality: { greater_than_or_equal_to: -180, less_than_or_equal_to: 180 }
16+
validates :latitude, numericality: { greater_than_or_equal_to: -90, less_than_or_equal_to: 90 }, allow_nil: true
17+
validates :longitude, numericality: { greater_than_or_equal_to: -180, less_than_or_equal_to: 180 }, allow_nil: true
1818

1919
def self.permitted_attributes(id: false, destroy: false, exclude_extra: false)
2020
super + %i[longitude latitude elevation]
@@ -24,6 +24,14 @@ def geocoded?
2424
latitude.present? && longitude.present?
2525
end
2626

27+
def latitude= arg
28+
super if arg.present?
29+
end
30+
31+
def longitude= arg
32+
super if arg.present?
33+
end
34+
2735
def to_leaflet_point
2836
return nil unless geocoded?
2937

0 commit comments

Comments
 (0)