首先,这颗宝石看起来棒极了——感谢@apneadiving。我希望有一天能够做出贡献——一旦我弄清楚如何正确使用它:-\
一个可怕的新手问题,我担心......而且我知道我应该能够仅仅基于 Ruby 主义来解决它......但我没能弄清楚我做错了什么......
我无法克服这个错误:
NoMethodError (undefined method `gmaps4rails_options' for <WaterSupply>...
我已经探索了许多不同的方式来编码坐标,但错误——我相信——只是在acts_as_gmappable
某种程度上不“工作”。我的模型是这样的:
class WaterSupply
include Gmaps4rails::ActsAsGmappable
include MongoMapper::Document
acts_as_gmappable :process_geocoding => false
ensure_index [[:loc, '2d']]
def initialize
puts Gmaps4rails::ActsAsGmappable.inspect
puts "*"*50
end
key :name, String, :required => true
# TODO break this address/geo stuff out into a separate Location class
key :loc, GeoPoint, :default => [40.34962381,-74.75102367]
key :gmaps, Boolean
key :address, String
key :city, String
key :zip, String
key :country, String
def gmaps4rails_address
"#{self.address}, #{self.zip} #{self.city}, #{self.country}"
end
end
任何帮助,将不胜感激。我可以看到一张空白地图,没有任何模型实例数据:-p
一旦我开始工作,我将添加一篇博客文章或一个 wiki 页面以使用 MongoMapper 和 Gmaps4Rails!