我正在使用 geokit-rails3 gem 在特定大学范围内的所有大学中查找产品。一个学院 has_many products 和一个产品属于学院,还有另一个类别模型 has_many products 和 product belongs_to category。但是,当我尝试使用 geokit 根据地址从数据库中查找大学时,它告诉我表中缺少 lat 列。
大学移民是
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))
任何提示如何解决这个问题?