Ruby on rails rails geocoder无法自定义模型列名lat和lng

Ruby on rails rails geocoder无法自定义模型列名lat和lng,ruby-on-rails,rails-geocoder,Ruby On Rails,Rails Geocoder,到我的城市.rb添加 geocoded_by :latitude => :lat, :longitude => :lng 那么当我打电话的时候 city = City.near(city_name).first 我明白了 ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR: column cities.latitude does not exist 在city.rb中,通过方法传递到地理编码_的参数正确: 您

到我的城市.rb添加

geocoded_by :latitude  => :lat, :longitude => :lng
那么当我打电话的时候

city = City.near(city_name).first
我明白了

ActiveRecord::StatementInvalid: PG::UndefinedColumn: ERROR:  column cities.latitude does not exist

在city.rb中,通过方法传递到地理编码_的参数正确:

您需要首先指定,如果您正在执行普通地理编码,则意味着将字符串地址转换为纬度和经度。正确的代码应该如下所示

geocoded_by :address, :latitude  => :lat, :longitude => :lon # ActiveRecord
其中address是存储要搜索的字符串的字段,也可以是创建字符串以获取其等效纬度和经度的方法

如果要执行相反的操作,则意味着获取特定坐标的地址,然后应使用:

reverse_geocoded_by :latitude, :longitude, :address => :location  # ActiveRecord

这两种方法都不管用。主要问题是我的DB列是:lat和:lng。我并没有试图对任何东西进行地理编码,从地址到lat,lng,我有名字和lat lng,我只是想在我的数据库中找到附近的其他城市。