简体   繁体   中英

Can we check the uniqueness of latitude and longitude while using gecoder gem?

Using geocoder gem in my web services , the server side we need to validate the uniqueness of location added.Is this possible with the geocoder gem, we don't want the same location twice in our database.

Any help will be appreciated?

在模型上定义唯一性验证:

validates :latitude, uniqueness: {scope: :longitude}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM