cartographer icon indicating copy to clipboard operation
cartographer copied to clipboard

undefined method `name' for :normal:Symbol

Open baltuonis opened this issue 14 years ago • 11 comments

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_run__362454126__process_action__330680296__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' <internal:prelude>:10:insynchronize' rack (1.2.1) lib/rack/lock.rb:11:in call' actionpack (3.0.3) lib/action_dispatch/middleware/static.rb:30:incall' railties (3.0.3) lib/rails/application.rb:168:in call' railties (3.0.3) lib/rails/application.rb:77:inmethod_missing' railties (3.0.3) lib/rails/rack/log_tailer.rb:14:in call' rack (1.2.1) lib/rack/content_length.rb:13:incall' 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:inservice' /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:inblock in start_thread'

baltuonis avatar Jan 12 '11 23:01 baltuonis

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

ghost avatar Jan 16 '11 14:01 ghost

+1 same here

fery avatar Jan 22 '11 14:01 fery

Same here :/

nicinabox avatar Feb 01 '11 18:02 nicinabox

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!

pasine avatar Feb 11 '11 14:02 pasine

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

nicinabox avatar Feb 11 '11 14:02 nicinabox

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

cmezak avatar Feb 15 '11 02:02 cmezak

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.

ebunomoni avatar Feb 23 '11 17:02 ebunomoni

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

nicinabox avatar Feb 23 '11 20:02 nicinabox

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.

ebunomoni avatar Feb 24 '11 10:02 ebunomoni

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.

nicinabox avatar Feb 24 '11 16:02 nicinabox

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.

gordonbanderson avatar Apr 01 '11 04:04 gordonbanderson