让 Gmaps4Rails 与 MongoMapper 一起工作
首先,这颗宝石看起来棒极了——感谢@apneadiving。我希望有一天能够做出贡献 - 一旦我弄清楚如何正确使用它:-\
我担心这是一个可怕的新手问题......而且我知道我应该能够仅基于 Ruby-isms 来解决它...但我没能弄清楚我做错了什么...
我无法克服这个错误:
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!
First off, this gem looks awesome -- thanks @apneadiving. I hope to be able to contribute one day -- once I figure out how to use it properly :-\
A horribly newbie question, I fear... and I know I should be able to figure it out based solely on Ruby-isms... But I have failed to figure out what I am doing wrong...
I cannot get past this error:
NoMethodError (undefined method `gmaps4rails_options' for <WaterSupply>...
I have explored many different ways to encode the coords, but the error -- I believe -- is simply in the acts_as_gmappable
somehow not "working." My model is this:
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
Any help would be appreciated. I can get a blank map to appear, just nothing with any model instance data :-p
Once I get things working, I'll add a blog post or a wiki page for using MongoMapper and Gmaps4Rails!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我有一个使用 MongoMapper 的示例 这里
模型类如下所示:
I got an example working with MongoMapper here
Model class looks like this: