我正在使用geokit-rails3 gem在特定大學範圍內的所有學院中查找產品。一所大學有多種產品和一種產品屬於大學,還有另一種產品和產品屬於類別的分類模式。但是,當我嘗試從使用geokit的地址的數據庫中找到大學時,它告訴我在我的表格中缺少lat coloumn。Geokit plus Rails 3.1.1,經緯度問題。
院校遷移
create_table :colleges do |t|
t.string :name
t.text :address
t.string :city
t.string :state
t.integer :zipcode
t.timestamps
控制器
@products = College.within(5, :origin=>@current_product.college.address).product
錯誤:
Mysql::Error: Unknown column 'colleges.lat' in 'field list': SELECT `colleges`.*,
(ACOS(least(1,COS(0.3223824452162744)*COS(1.2891920858347756)*COS(RADIANS(colleges.lat))*COS(RADIANS(colleges.lng))+
COS(0.3223824452162744)*SIN(1.2891920858347756)*COS(RADIANS(colleges.lat))*SIN(RADIANS(colleges.lng))+
SIN(0.3223824452162744)*SIN(RADIANS(colleges.lat))))*3963.19)
AS distance FROM `colleges` WHERE ((colleges.lat>18.398868573573203 AND colleges.lat<18.543438426426793 AND colleges.lng>73.78905443427034 AND colleges.lng<73.94147656572967)) AND ((
(ACOS(least(1,COS(0.3223824452162744)*COS(1.2891920858347756)*COS(RADIANS(colleges.lat))*COS(RADIANS(colleges.lng))+
COS(0.3223824452162744)*SIN(1.2891920858347756)*COS(RADIANS(colleges.lat))*SIN(RADIANS(colleges.lng))+
SIN(0.3223824452162744)*SIN(RADIANS(colleges.lat))))*3963.19)
<= 5))
任何暗示該如何解決這個問題呢?
您是否有lat列?看來geokit-rails3不會爲你創建一個。 – tommasop
在這種情況下,我沒有緯度列 –