开发者

Setting gmaps to false, can't update geocoding location

I'm using the great gem gmaps4rails to put a Google Map on my Ruby on Rails site. I'm following this page on the wiki and trying to control when the calculated latitude and longitude should be updated, by setting the gmaps field to false. I can't seem to get it to work.

In my User model, I've got this:

class User < ActiveRecord::Base
   acts_as_gmappable

   attr_accessible :latitude, :longitude, :address, :gmaps

   def gmaps4rails_address
      address
   end

I'm sure I'm missing something simple here. I'm changing the address field to something new directly in the database using SQLite Database Browser, setting latitude and longitude to 0, and I've tried setting gmaps to false, f, 0, null (not sure what false is in SQLite)... then loading the map again by refreshing the page. It always shows the marker at 0,0..

I thought all I had to do was define a boolean called gmaps, and when it is set to fa开发者_如何转开发lse, upon loading the map, it should recalculate the lat/long by geocoding the address. What am I missing?

Thanks!


Look at the test here, line 72.

The coordinates aren't refreshed on map load, this is part of the validation process of an acts_as_gmappable model.

model_instance.update_attributes({ :sec_address => "new address", 
                                   :gmaps       => false })
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜