我正在使用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
在这种情况下,我没有纬度列 –