简体   繁体   English

我们可以在使用gecoder宝石时检查经度和纬度的唯一性吗?

[英]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. 在我的Web服务中使用geocoder gem时,我们需要在服务器端验证添加的位置的唯一性。对于geocoder gem这是可能的,我们不希望数据库中的相同位置两次。

Any help will be appreciated? 任何帮助将不胜感激?

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

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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