簡體   English   中英

我們可以在使用gecoder寶石時檢查經度和緯度的唯一性嗎?

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

在我的Web服務中使用geocoder gem時,我們需要在服務器端驗證添加的位置的唯一性。對於geocoder gem這是可能的,我們不希望數據庫中的相同位置兩次。

任何幫助將不勝感激?

在模型上定義唯一性驗證:

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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM