Gmaps4rails - 数据库中的经度和纬度未更新.<嵌套形式> [英] Gmaps4rails - longitude and latitude in database no updated. <nested form>

查看:60
本文介绍了Gmaps4rails - 数据库中的经度和纬度未更新.<嵌套形式>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个带有属性名称、州、经度和纬度的模型地点.一个模型 travel_plan 有很多地方.

I have a model place with attributes name, state, longitude, and latitude. A model travel_plan has many places.

我在旅行计划表单中使用嵌套表单 gem.

I'm using nested form gem for places in the travel plan form.

我的问题是更新名称和状态时经度和纬度没有更新.

My problem is that the longitude and latitude were not updated when name and state were updated.

在我的地方.rb

belongs_to :travel_plan  

acts_as_gmappable

def gmaps4rails_address
  "#{name},#{state}"
end

def gmaps4rails_infowindow
  "<h4>#{name}</h4>"
end

推荐答案

答案在于 这里.

这两个设置与您的问题特别相关:

These two settings are particularly relevant for your question:

:check_process : true/false(如果设置为 false,将进行地理编码每次保存/更新)

:check_process : true/false (if set to false, geocoding will be made at every save/update)

:checker : 字符串(仅当 check_process 为真时),可以是一个方法或 db 列布尔值

:checker : string (only if check_process is true), could be a method or a db column boolean

这篇关于Gmaps4rails - 数据库中的经度和纬度未更新.&lt;嵌套形式&gt;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆