【发布时间】:2015-02-09 22:21:14
【问题描述】:
我收到一个模型发生的错误,而不是另一个模型。我可以运行 Job.all.within(5, :origin => [0, 0]),但不能运行 User.all.within(5, :origin => [0, 0]),即使它们的模型中具有相同的信息:acts_as_mappable lng_column_name: :longitude, lat_column_name: :latitude
对于损坏的情况,它似乎在这里损坏(这是来自 Geokit gem 的代码):
def within(distance, options = {})
options[:within] = distance
#geo_scope(options)
where(distance_conditions(options)) # HERE
end
哪里,如果我打断,我可以输出:
>> options
=> {:within=>5}
>> distance_conditions(options)
!! #<TypeError: no implicit conversion of Symbol into Integer>
发生了什么事?
【问题讨论】:
-
立即在我的文件中找到了阻止它的行。我也在使用 Geocoder gem。我的
Job模型中的geocoded_by :postcode行打破了它。如果我使用 geokit,我可能可以取出 Geocoder gem。 -
好的,所以修复结果是:您需要在模型中将“acts_as_mappable”放在“geocoded_by”之后。
-
您能否将其发布为答案并接受它,我几乎没有看到评论,它解决了我的问题
标签: ruby-on-rails ruby geokit