Skip to content
New issue

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

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

before_validation_on_create removed in Rails 3 #16

Closed
bobbymarko opened this issue Apr 8, 2010 · 7 comments
Closed

before_validation_on_create removed in Rails 3 #16

bobbymarko opened this issue Apr 8, 2010 · 7 comments

Comments

@bobbymarko
Copy link

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
Copy link
Author

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
Copy link
Member

andre commented Apr 8, 2010

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
Copy link
Author

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
Copy link
Member

andre commented Apr 9, 2010

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

@bobbymarko
Copy link
Author

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
Copy link

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
Copy link
Member

ryankopf commented Jan 8, 2021

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

@ryankopf ryankopf closed this as completed Jan 8, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants