Search code examples
ruby-on-railsrubyruby-on-rails-3google-mapsgmaps4rails

Rails 3 google maps


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.


Solution

  • 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