0
我有一個位置模型,它本身有一個經度和緯度。我要的是其拉/長是在一定區域內交易,所以我想這:搜索對象相關對象SQL ActiveRecord
boundary = self.user.boundary
max_lat, max_lng = boundary.max_coords.latitude, boundary.max_coords.lng
min_lat, min_lng = boundary.min_coords.latitude, boundary.min_coords.lng
lat, long = self.user.location.latitude, self.user.location.longitude
self.all_deals = Deal.where('location.latitude <= ? AND location.latitude >= ? AND location.longitude <= ? AND location.longitude >= ?', max_lat, min_lat, max_lng, min_lng).limit(10)
SQL拋出一個異常說有沒有列「location.latitude」。我怎麼能寫同樣的東西,但要麼使用ActiveRecord(首選)或原始SQL?