Validating longitude / latitude with geocoder gem

前端 未结 1 793
轻奢々
轻奢々 2021-01-29 02:52

I followed this Geocoder Railscast & I\'m playing around with it to see if I can add validation to the longitude & latitude coordinates returned by the Geocoder Gem inca

相关标签:
1条回答
  • 2021-01-29 03:48

    Why can't you :geocode the Location before validation? :address_changed? will return true even for new records if any of those fields have changed. Validate it and if it returns invalid lat/lng values then your :latitude presence validation will fail.

    Just change that after_validation to before_validation.

    0 讨论(0)
提交回复
热议问题