简体   繁体   English

TypeError:没有使用geokit-rails搜索将Symbol隐式转换为Integer

[英]TypeError: no implicit conversion of Symbol into Integer for search with geokit-rails

I've got the geokit-rails gem installed with geocoder, and have loaded my configuration correctly with the right API keys and settings. 我已经在geocoder中安装了geokit-rails gem,并使用正确的API密钥和设置正确加载了我的配置。 I've properly constructed ActiveRecord objects that have encoded lat and lng columns with float values. 我已经正确构造了ActiveRecord对象,该对象已使用浮点值对latlng列进行了编码。 Now I am trying to simply search for venues (Venue activerecord) that are within 100km of the given origin as so: 现在,我试图简单地搜索距给定起点100公里以内的场所(Venue activerecord):

Venue.within(100, origin: Geokit::LatLng.new(-27.12,124.2141))

Yet I keep receiving the error: 但是我一直收到错误:

TypeError: no implicit conversion of Symbol into Integer
    from /usr/local/lib/ruby/gems/2.1.0/gems/geocoder-1.2.3/lib/geocoder/sql.rb:14:in `[]'
    from /usr/local/lib/ruby/gems/2.1.0/gems/geocoder-1.2.3/lib/geocoder/sql.rb:14:in `full_distance'
    from /usr/local/lib/ruby/gems/2.1.0/gems/geocoder-1.2.3/lib/geocoder/stores/active_record.rb:157:in `distance_sql'
    from /usr/local/lib/ruby/gems/2.1.0/gems/geokit-rails-2.0.1/lib/geokit-rails/acts_as_mappable.rb:228:in `distance_conditions'
    from /usr/local/lib/ruby/gems/2.1.0/gems/geokit-rails-2.0.1/lib/geokit-rails/acts_as_mappable.rb:108:in `within'
    from (irb):46
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands/console.rb:90:in `start'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands/console.rb:9:in `start'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:69:in `console'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands/commands_tasks.rb:40:in `run_command!'
    from /usr/local/lib/ruby/gems/2.1.0/gems/railties-4.1.0/lib/rails/commands.rb:17:in `<top (required)>'
    from bin/rails:4:in `require'
    from bin/rails:4:in `<main>'

Would someone help? 有人帮忙吗?

You could use Geokit within method with Lat&Long directly - from docs . 您可以通过docs直接在Lat&Long的方法内使用Geokit。 Fe: :origin => [37.792,-122.393]. Fe :: :origin => [37.792,-122.393]. In your case Venue.within(100, origin: [-27.12,124.2141]) 在您的情况下, Venue.within(100, origin: [-27.12,124.2141])

Why do you use Geokit::LatLng.new for this? 为什么要为此使用Geokit :: LatLng.new?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM