我正在尝试找到一种方法来加载gmaps4rails地图到自定义格式字段(用于活动管理)
我有这个:
class GmapInput < Formtastic::Inputs::StringInput
def to_html
gmaps4rails(Location.new)
end
end它正在触发,但我得到了错误:
undefined method `gmaps4rails' for #<GmapInput:0x007f9cae5b2780>我认为这是因为gmaps4rails还没有加载。我怎样才能确保它被加载?
发布于 2012-11-11 05:01:52
嗯,从来没有用过形式化,但是……
我猜问题源于这样一个事实:gmaps4rails是一个帮助器,而您的类没有访问它的权限。
在标准表单构建器中,您只需将帮助器的调用委托给@template (即@template.gmaps4rails )。
顺便说一句,还有另一件奇怪的事情:为什么要把Location.new传递给gmaps4rails?它不能用这样的对象做很多事情:它需要json。
https://stackoverflow.com/questions/13315509
复制相似问题