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

before_validation_on_create removed in Rails 3 #16

Closed bobbymarko closed 3 years ago

bobbymarko commented 14 years ago

Rails 3 is giving me a "no method found" error when I enable auto_geocode. The validation should be called like so: before_validation :auto_geocode_address, :on => :create because before_validation_on_create has been deprecated. Although when I change the callback to that code WEBrick crashes so there's more to the bug.

Running Rails 3 Beta 2 with ruby 1.9.2

bobbymarko commented 14 years ago

Calling just before_validation :auto_geocode_address is working for me. Will there be any issues with not specifying the callback for only on create?

andre commented 14 years ago

Yes, if you're using the autogeocode option, you'll hit the geocoding we service every time you save the instance. Which will make things very slow.

The plugin is going to have a lot of other issues with Rails3. There will be problems in the way we munge SQL for the distance clauses. I played around with Rails3 some this evening and there are still a lot of failing tests.

bobbymarko commented 14 years ago

For the distance clause issues, I got things working by adding merge_conditions from the Rails 2 ActiveRecord::Base into acts_as_mappable.rb. It's a temporary fix until the queries are switched to the new query api.

andre commented 14 years ago

That's working? Interesting -- I tried that and still had issues. Awesome if that's all it takes though.

bobbymarko commented 14 years ago

It worked for a very specific instance and then when I tried to do something a little more complex I got the Unknown key(s): origin, within error that is mentioned here: http://www.railsplugins.org/plugins/124-geokit-rails So I spoke too soon!

activefx commented 14 years ago

Changing the plugin code from before_validation_on_create :auto_geocode_address to before_validation :auto_geocode_address, :on => :create in acts_as_mappable.rb got geocoding working for me on rails 3 beta 2 and ruby 1.9.2

ryankopf commented 3 years ago

This change appears to have been implemented. Closing as fixed.