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

Changes to address aren't saved #208

Closed danmaz74 closed 12 years ago

danmaz74 commented 12 years ago

When the address in the model is changed, the map location isn't updated automatically - this is known and I found a solution on stackexchange.

But I wonder if it wouldn't be possible to add to the gem itself a solution like this: http://stackoverflow.com/a/10574422/855874

apneadiving commented 12 years ago

I wouldn't add extra complexity to the gem for this purpose.

Concerning your solution, I don't like the idea to duplicate data in the db. You'd rather do something like (untested):

attr_accessor :latest_address

after_initialize :set_latest_address

before_validation :check_g4r_address

def set_latest_address
   self.latest_address = self.gmaps4rails_address
end

def check_g4r_address
   self.gmaps = false if self.latest_address != self.gmaps4rails_address
end
danmaz74 commented 12 years ago

Ok, no problem, it was just an idea ;)

Dan

On 13 May 2012 22:40, Benjamin Roth < reply@reply.github.com

wrote:

I wouldn't add extra complexity to the gem for this purpose.

Concerning your solution, I don't like the idea to duplicate data in the db. You'd rather do something like (untested):

attr_accessor :latest_address

after_initialize :set_latest_address

before_validation :check_g4r_address

def set_latest_address self.latest_address = self.gmaps4rails_address end

def check_g4r_address self.gmaps = false if self.latest_address != self.gmaps4rails_address end


Reply to this email directly or view it on GitHub:

https://github.com/apneadiving/Google-Maps-for-Rails/issues/208#issuecomment-5679318