joshuamiller / cartographer

Google Maps on Rails
72 stars 39 forks source link

undefined method `name' for :normal:Symbol #1

Open baltuonis opened 13 years ago

baltuonis commented 13 years ago

Rails 3 Ruby 1.9.2

Done everything like in example

NoMethodError in Map#index ~/app/views/map/index.html.haml where line #2 raised: undefined method `name' for :normal:Symbol

Extracted source (around line #2) (HAML): 1: = raw Cartographer::Header.new.to_s 2: = raw @map.to_html

Trace: vendor/plugins/cartographer/lib/v3/cartographer/gmarker.rb:57:in to_js' vendor/plugins/cartographer/lib/v3/cartographer/gmap.rb:174:inblock in to_js' vendor/plugins/cartographer/lib/v3/cartographer/gmap.rb:173:in each' vendor/plugins/cartographer/lib/v3/cartographer/gmap.rb:173:into_js' vendor/plugins/cartographer/lib/v3/cartographer/gmap.rb:88:in to_html' app/views/map/index.html.haml:2:in_app_views_map_index_html_haml_869769418_90224840_303366198' actionpack (3.0.3) lib/action_view/template.rb:135:in block in render' activesupport (3.0.3) lib/active_support/notifications.rb:54:ininstrument' actionpack (3.0.3) lib/action_view/template.rb:127:in render' actionpack (3.0.3) lib/action_view/render/rendering.rb:59:inblock in _render_template' activesupport (3.0.3) lib/active_support/notifications.rb:52:in block in instrument' activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:ininstrument' activesupport (3.0.3) lib/active_support/notifications.rb:52:in instrument' actionpack (3.0.3) lib/action_view/render/rendering.rb:56:in_render_template' actionpack (3.0.3) lib/action_view/render/rendering.rb:26:in render' haml (3.0.25) lib/haml/helpers/action_view_mods.rb:13:inrender_with_haml' actionpack (3.0.3) lib/abstract_controller/rendering.rb:114:in _render_template' actionpack (3.0.3) lib/abstract_controller/rendering.rb:108:inrender_to_body' actionpack (3.0.3) lib/action_controller/metal/renderers.rb:47:in render_to_body' actionpack (3.0.3) lib/action_controller/metal/compatibility.rb:55:inrender_to_body' actionpack (3.0.3) lib/abstract_controller/rendering.rb:101:in render_to_string' actionpack (3.0.3) lib/abstract_controller/rendering.rb:92:inrender' actionpack (3.0.3) lib/action_controller/metal/rendering.rb:17:in render' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:40:inblock (2 levels) in render' activesupport (3.0.3) lib/active_support/core_ext/benchmark.rb:5:in block in ms' /home/sarunas/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/benchmark.rb:309:inrealtime' activesupport (3.0.3) lib/active_support/core_ext/benchmark.rb:5:in ms' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:40:inblock in render' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:78:in cleanup_view_runtime' activerecord (3.0.3) lib/active_record/railties/controller_runtime.rb:15:incleanup_view_runtime' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:39:in render' vendor/plugins/active_scaffold/lib/extensions/action_controller_rendering.rb:13:inrender_with_active_scaffold' actionpack (3.0.3) lib/action_controller/metal/implicit_render.rb:10:in default_render' actionpack (3.0.3) lib/action_controller/metal/implicit_render.rb:5:insend_action' actionpack (3.0.3) lib/abstract_controller/base.rb:151:in process_action' actionpack (3.0.3) lib/action_controller/metal/rendering.rb:11:inprocess_action' actionpack (3.0.3) lib/abstract_controller/callbacks.rb:18:in block in process_action' activesupport (3.0.3) lib/active_support/callbacks.rb:460:in_run362454126process_action330680296__callbacks' activesupport (3.0.3) lib/active_support/callbacks.rb:409:in _run_process_action_callbacks' activesupport (3.0.3) lib/active_support/callbacks.rb:93:inrun_callbacks' actionpack (3.0.3) lib/abstract_controller/callbacks.rb:17:in process_action' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:30:inblock in process_action' activesupport (3.0.3) lib/active_support/notifications.rb:52:in block in instrument' activesupport (3.0.3) lib/active_support/notifications/instrumenter.rb:21:ininstrument' activesupport (3.0.3) lib/active_support/notifications.rb:52:in instrument' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:29:inprocess_action' actionpack (3.0.3) lib/action_controller/metal/rescue.rb:17:in process_action' actionpack (3.0.3) lib/abstract_controller/base.rb:120:inprocess' actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in process' actionpack (3.0.3) lib/action_controller/metal.rb:138:indispatch' actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in dispatch' actionpack (3.0.3) lib/action_controller/metal.rb:178:inblock in action' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:in call' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:62:indispatch' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:27:in call' rack-mount (0.6.13) lib/rack/mount/route_set.rb:148:inblock in call' rack-mount (0.6.13) lib/rack/mount/code_generation.rb:93:in block in recognize' rack-mount (0.6.13) lib/rack/mount/code_generation.rb:68:inoptimized_each' rack-mount (0.6.13) lib/rack/mount/code_generation.rb:92:in recognize' rack-mount (0.6.13) lib/rack/mount/route_set.rb:139:incall' actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:492:in call' haml (3.0.25) lib/sass/plugin/rack.rb:41:incall' warden (1.0.3) lib/warden/manager.rb:35:in block in call' warden (1.0.3) lib/warden/manager.rb:34:incatch' warden (1.0.3) lib/warden/manager.rb:34:in call' actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:incall' actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in call' rack (1.2.1) lib/rack/methodoverride.rb:24:incall' actionpack (3.0.3) lib/action_dispatch/middleware/params_parser.rb:21:in call' actionpack (3.0.3) lib/action_dispatch/middleware/flash.rb:182:incall' actionpack (3.0.3) lib/action_dispatch/middleware/session/abstract_store.rb:149:in call' actionpack (3.0.3) lib/action_dispatch/middleware/cookies.rb:295:incall' activerecord (3.0.3) lib/active_record/query_cache.rb:32:in block in call' activerecord (3.0.3) lib/active_record/connection_adapters/abstract/query_cache.rb:28:incache' activerecord (3.0.3) lib/active_record/query_cache.rb:12:in cache' activerecord (3.0.3) lib/active_record/query_cache.rb:31:incall' activerecord (3.0.3) lib/active_record/connection_adapters/abstract/connection_pool.rb:353:in call' actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:46:inblock in call' activesupport (3.0.3) lib/active_support/callbacks.rb:415:in _run_call_callbacks' actionpack (3.0.3) lib/action_dispatch/middleware/callbacks.rb:44:incall' rack (1.2.1) lib/rack/sendfile.rb:107:in call' actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:incall' actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in call' railties (3.0.3) lib/rails/rack/logger.rb:13:incall' rack (1.2.1) lib/rack/runtime.rb:17:in call' activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:incall' rack (1.2.1) lib/rack/lock.rb:11:in `block in call'

:10:in`synchronize' rack (1.2.1) lib/rack/lock.rb:11:in `call' actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:in`call' railties (3.0.3) lib/rails/application.rb:168:in `call' railties (3.0.3) lib/rails/application.rb:77:in`method_missing' railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in `call' rack (1.2.1) lib/rack/content_length.rb:13:in`call' rack (1.2.1) lib/rack/handler/webrick.rb:52:in `service' /home/sarunas/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/webrick/httpserver.rb:111:in`service' /home/sarunas/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/webrick/httpserver.rb:70:in `run' /home/sarunas/.rvm/rubies/ruby-1.9.2-head/lib/ruby/1.9.1/webrick/server.rb:183:in`block in start_thread'
ghost commented 13 years ago

+1 Same issue occurring for me too, with ruby 1.8.7 and rails 3 (not using HAML though)

fery commented 13 years ago

+1 same here

nicinabox commented 13 years ago

Same here :/

pasine commented 13 years ago

I found a solution here.

http://stackoverflow.com/questions/4701798/google-maps-api-with-rails-3-0

I solved the issue name with the solution suggested by Lucas Efe. Then I had my map showed correctly adding

[Map]

as suggested in the accepted answer.

Good luck!

nicinabox commented 13 years ago

The proper "fix" is to add @map.icons << Cartographer::Gicon.new to your controller :)

cmezak commented 13 years ago

@nicinabox doing as you suggest did not affect the problem for me.

ebunomoni commented 13 years ago

Have there been any additional fixes/solutions around this? I've been trying to figure it out, and have attempted using the suggested fixes above, but to no avail.

nicinabox commented 13 years ago

This issue was fixed on Feb 4. If you have a version of cartographer from before that, make sure you clone the current state.

Also, don't forget to add @map.icons << Cartographer::Gicon.new to your controller (this wasn't documented before)

It should work just fine for you

ebunomoni commented 13 years ago

Thanks for the response.

Using your advice as well as some of the others, I was able to fix the root of my problems, the biggest one being that everywhere this great plugin is mentioned, it suggests an older version and so that's why I installed stale code. It's even in the installation notes of your README.markdown:

git://github.com/parolkar/cartographer.git vendor/plugins/cartographer

Can you update your README file to reflect the location of the updated clone for future installers:

git://github.com/joshuamiller/cartographer.git vendor/plugins/cartographer

The other thing is that an additional

tag is needed in the view to display the map. So users will need something like this:

<%= raw Cartographer::Header.new.to_s %> <%= raw @map.to_html %>

[Map]

Once again thanks for the great plugin and good luck to anyone else who may be run and good luck to anyone who runs across this error.

nicinabox commented 13 years ago

parolkar's version is a fork of the original (joshuamiller). his may be behind master by several commits. But you are right, the map div is missing from the readme.

gordonbanderson commented 13 years ago

The README has some inaccuracies and missing information, but I now have the markers example working.

@map = Cartographer::Gmap.new( 'map' )
@map.zoom = :bound
@map.debug = true
normal_icon = Cartographer::Gicon.new
@map.icons << normal_icon
marker1 = Cartographer::Gmarker.new(:name=> "taj_mahal", :marker_type =>    "Building",:position => [27.173006,78.042086], :icon => normal_icon, :info_window_url  => "/url_for_info_content")
marker2 = Cartographer::Gmarker.new(:name=> "raj_bhawan", :marker_type =>  "Building",
          :position => [28.614309,77.201353],
          :icon => normal_icon,
          :info_window_url => "/url_for_info_content")

@map.markers << marker1
@map.markers << marker2

The issue arises due to the default setting of the icon in gmarker.rb, line 9

@icon = options[:icon] || :normal

On rendering, line 58 fails

script << "#{@name} = new google.maps.Marker({map: null,position: new google.maps.LatLng(#{@position[0]}, #{@position[1]}), draggable: #{@draggable}, icon: #{@icon.name}}); \n"

This is because @icon.name is trying to evaluate :normal.nam which of course fails.

Definitely a bug, though easily fixable or workaroundable.