Rails 3 google maps

谁都会走 提交于 2019-12-24 22:47:54

问题


I'm trying to create a sample project with gmaps4rails gem: But getting an error:

undefined method `gmaps’ for #
Rails.root: /var/www/brandbk
Application Trace | Framework Trace | Full Trace
app/controllers/locations_controller.rb:46:in `block in create’
app/controllers/locations_controller.rb:45:in `create’
Request
Parameters:
{“utf8″=>”вњ“”,
“authenticity_token”=>”CSpi+VhUe8CtF+4R6zxMEXbB8ofa0QxUF1ntGl+N1Ss=”,
“location”=>{“address”=>”rwr”},
“commit”=>”Create Location”}

Like this: http://pastebin.com/zGP9Z7vE Can anyone help me please?

My models and controllers are valid and same as described on the project wiki. Thanks.


回答1:


It comes from here:

return true if gmaps4rails_options[:check_process] == true && self.send(gmaps4rails_options[:checker]) == true

Basically this line prevents geocoding if:

  • it's not requested
  • or if it's requested but not already done

So two ways to get rid of it:

  • set the check_process to false
  • add a boolean column to your model named gmaps (this could be done with a method as well)

Some more details here: https://github.com/apneadiving/Google-Maps-for-Rails/wiki/Model-Customization



来源:https://stackoverflow.com/questions/6103384/rails-3-google-maps

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!