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

After_create problem with acts_as_gmappable #157

Closed Dinuz closed 12 years ago

Dinuz commented 12 years ago

I built an app that creates a user model and automatically creates a profile model and a location model using the after_create callback method in the model. The model profile belongs to users, and users has one profile, and the model location belong to profile and profile has one location.

The model called location, use the gem geocoder with the current_ip address of the client machine, to pull out the current location of the user, and then save the address, the latitude and longitude in the same model.

Everything works perfectly and fine, except, when I try to add to the location model, acts_as_gmappable, then during the registration process, the same model is not more automatically created, and this prevent the creation of the database column address and obviously consequently, this will bring to an error of gmapsforails.

How I can use the after_create callback in the profile model, and then automatically create the location model, and its column (longitude, latitude, address, ip_address) and at the same time using after the acts_as_gmappable?

I think it's a problem related with which method is called before: the after_create or the gmapsforrails one...this because, if I cut from my location model the call to acts_as_gmappable, register the user, and after past back in the location model the acts_as_gmappable, everything works fine, and the google map is showed.

Thanks to everyone that could in someway highlight my mind...

apneadiving commented 12 years ago

Please askquestions on stavkoverflow (and show code there)