apneadiving / Google-Maps-for-Rails

Enables easy Google map + overlays creation in Ruby apps
https://apneadiving.github.io/
MIT License
2.26k stars 382 forks source link

With :validation => false option, if geocoding fails, is it ever retried? #339

Closed mtc2013 closed 10 years ago

mtc2013 commented 11 years ago

My initial cucumber scenarios seem to indicate it keeps the old geo-coding coordinates when an address is updated but geo-coding fails. It then doesn't seem to retry the geocoding when the map is refreshed. Is this accurate?

apneadiving commented 11 years ago

yes it is.

`validation: false' just prevent you from having an error added to your model. https://github.com/apneadiving/Google-Maps-for-Rails/blob/master/lib/gmaps4rails/model_handler.rb#L67

I don't advise you to keep this option.

mtc2013 commented 11 years ago

The wider context here is we want to give users the ability to edit an address but keep their edit in place even if geocoding fails for some reason, but then let the app attempt to recode it later so that the user is not disrupted in his workflow

Is there some easy way of achieving this with your gem?

apneadiving commented 11 years ago

You could:

pavloo commented 11 years ago

I'm tryin to imlpement the scenario u've described in ur last reply, but I have problems: when validation fails, I remove validation errors in after_validation hook and I still need to save this record with invalid address (as validate? is false, transaction rollbacks and save is not performed). How can i do this? And in after_validation hook I try to set self.gmaps = false, but it still tries to geocode if I run @model.save! . Thanks in advance! Your support is great!