2

I'm getting an error that happens for one model and not the other. I can run Job.all.within(5, :origin => [0, 0]), but not User.all.within(5, :origin => [0, 0]), even though they have the same info in their models: acts_as_mappable lng_column_name: :longitude, lat_column_name: :latitude

For the broken case, it seems to be breaking here (this is code from the Geokit gem):

 def within(distance, options = {})
    options[:within] = distance
    #geo_scope(options)
    where(distance_conditions(options))  # HERE
  end

Where, if I interrupt, I can output:

>> options
=> {:within=>5}
>> distance_conditions(options)
!! #<TypeError: no implicit conversion of Symbol into Integer>

What's going on?

Joel
  • 4,503
  • 1
  • 27
  • 41
Will Taylor
  • 1,994
  • 2
  • 23
  • 36
  • 1
    Immediately found the line in my files that brakes it. I was also using the Geocoder gem. The line `geocoded_by :postcode` in my `Job` model was breaking it. I can probably take the Geocoder gem out if I'm using geokit. – Will Taylor Feb 09 '15 at 22:23
  • 1
    Ok, so the fix turns out to be: You need "acts_as_mappable" to be after "geocoded_by" in your model. – Will Taylor Feb 10 '15 at 17:17
  • Can you post that as an answer and accept it please, I almost didn't see the comment and it solved my issue – Viktor Jan 31 '20 at 13:52

2 Answers2

0

There seems a dependency issue with geocoder gem. Removing geocoder gem should work

 Location.within(5, :origin => [37.792,-122.393])
aashish
  • 2,453
  • 1
  • 21
  • 19
0

The fix for me turned out to be: You need "acts_as_mappable" to be after "geocoded_by" in your model.

Will Taylor
  • 1,994
  • 2
  • 23
  • 36