【问题标题】:Geokit Rails: no implicit conversion of Symbol into IntegerGeokit Rails:没有将符号隐式转换为整数
【发布时间】: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


【解决方案1】:

geocoder gem 似乎存在依赖性问题。删除 geocoder gem 应该可以工作

 Location.within(5, :origin => [37.792,-122.393])

【讨论】:

    【解决方案2】:

    对我的修复结果是:您需要在模型中将“acts_as_mappable”放在“geocoded_by”之后。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-01-19
      • 2023-03-20
      • 1970-01-01
      • 2014-04-03
      • 2020-04-03
      相关资源
      最近更新 更多