Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

Already on GitHub? Sign in to your account

Records have invalid ids when using all(:within => distance, :origin => location) on a has_many :through association #14

myronmarston opened this Issue Mar 24, 2010 · 8 comments


None yet
6 participants

The problem is that geokit-rails sets the find's :select option to "*", and the has_many :through association uses a join...causing it to include multiple id columns. I've got a fix here:


It'd be nice to get my fix pulled into the official repo. How do you like to receive patches? I sent a pull request a while ago and never got a response.

Ha, wish I had read through the issues list before implementing this myself (http://github.com/feldpost/geokit-rails/commit/34137021ee2d9970e381aa01a840fba9517b64f7). But since your fix is actually tested, here's my +1 for applying this.

Flink commented Jul 7, 2010

Thanks for your patch! I was running into the same issue. Too bad your patch is still not included :(

I'm not sure why my patch hasn't been included yet. I sent a pull request, waited a while, opened this ticket, waited a while, and asked about the contribution process on the google group.

It's definitely frustrating to spend time working on a good patch, only to have it ignored. You can try contacting andre to encourage him to apply my patch.

somebox commented Oct 4, 2010

This patch is pretty important. Without it, when you do a distance search with joined models, the results have invalid ids (and other columns too, if models have the same column names). Andre should have included this already...

It appears to me that Andre is no longer maintaining geokit-rails. The project hasn't had a commit in over a year, and there are 6-month old patches (like mine) that have test coverage and fix major bugs that he's simply ignored.


ghost commented Oct 8, 2010

I've attempted to contact Andre. If no updates happen on this, I suggest we look for another maintainer.

I would be very interested to see one of you pick up the project as a fork. You all seem to know enough about the plugin and Rails 3 to be able to make it happen.

Are any of you able to comment on this error?

Entry.find(:all, :origin => 'Bath, UK')
NoMethodError: undefined method error' for nil:NilClass from /Library/Ruby/Gems/1.8/gems/activesupport-3.0.1/lib/active_support/whiny_nil.rb:48:inmethod_missing'
from /Library/Ruby/Gems/1.8/gems/geokit-1.5.0/lib/geokit/geocoders.rb:629:in do_geocode' from /Library/Ruby/Gems/1.8/gems/geokit-1.5.0/lib/geokit/geocoders.rb:623:ineach'
from /Library/Ruby/Gems/1.8/gems/geokit-1.5.0/lib/geokit/geocoders.rb:623:in do_geocode' from /Library/Ruby/Gems/1.8/gems/geokit-1.5.0/lib/geokit/geocoders.rb:126:ingeocode'
from /Library/Ruby/Gems/1.8/gems/geokit-1.5.0/lib/geokit/mappable.rb:280:in normalize' from /Library/Ruby/Gems/1.8/gems/geokit-rails-1.1.4/lib/geokit-rails/acts_as_mappable.rb:398:innormalize_point_to_lat_lng'
from /Library/Ruby/Gems/1.8/gems/geokit-rails-1.1.4/lib/geokit-rails/acts_as_mappable.rb:358:in extract_origin_from_options' from /Library/Ruby/Gems/1.8/gems/geokit-rails-1.1.4/lib/geokit-rails/acts_as_mappable.rb:248:inprepare_for_find_or_count'
from /Library/Ruby/Gems/1.8/gems/geokit-rails-1.1.4/lib/geokit-rails/acts_as_mappable.rb:152:in `find'
from (irb):41

The gem itself works like a charm, but trying to get it going in Rails is proving difficult.

Scratch that, just use gem geokit-rails3:


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment