geokit / geokit-rails

Official Geokit plugin for Rails/ActiveRecord. Provides location-based goodness for your Rails app. Requires the Geokit gem.
MIT License
1.57k stars 245 forks source link

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

Closed myronmarston closed 3 years ago

myronmarston commented 14 years ago

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:

http://github.com/myronmarston/geokit-rails/commit/a1caf6dcde7406988798685de73b2b87370539c5

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.

feldpost commented 14 years ago

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 14 years ago

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

myronmarston commented 14 years ago

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 14 years ago

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...

myronmarston commented 14 years ago

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.

reenhanced commented 14 years ago

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

philsturgeon commented 13 years ago

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.

philsturgeon commented 13 years ago

Scratch that, just use gem geokit-rails3:

https://github.com/jlecour/geokit-rails3

ryankopf commented 3 years ago

I am closing all issues that are more than 6 years old now, as the gem has had significant updates and is likely people with these old issues are no longer having the issues.

The updates that made the gem work with Rails 3 may have solved this.

If you are currently still experiencing this issue or need help feel free to submit a new issue, thank you.