2

我收到一个模型而不是另一个模型发生的错误。我可以运行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>

这是怎么回事?

4

2 回答 2

0

geocodergem似乎存在依赖性问题。移除geocoder宝石应该有效

 Location.within(5, :origin => [37.792,-122.393])
于 2017-12-31T18:49:53.857 回答
0

对我来说,解决方法是:您需要在模型中将“acts_as_mappable”放在“geocoded_by”之后。

于 2020-02-05T16:20:51.467 回答