cartographer
cartographer copied to clipboard
undefined method `name' for :normal:Symbol
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:in
block in to_js'
vendor/plugins/cartographer/lib/v3/cartographer/gmap.rb:173:in each' vendor/plugins/cartographer/lib/v3/cartographer/gmap.rb:173:in
to_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:in
instrument'
actionpack (3.0.3) lib/action_view/template.rb:127:in render' actionpack (3.0.3) lib/action_view/render/rendering.rb:59:in
block 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:in
instrument'
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:in
render_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:in
render_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:in
render_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:in
render'
actionpack (3.0.3) lib/action_controller/metal/rendering.rb:17:in render' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:40:in
block (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:in
realtime'
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:in
block 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:in
cleanup_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:in
render_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:in
send_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:in
process_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:in
run_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:in
block 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:in
instrument'
activesupport (3.0.3) lib/active_support/notifications.rb:52:in instrument' actionpack (3.0.3) lib/action_controller/metal/instrumentation.rb:29:in
process_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:in
process'
actionpack (3.0.3) lib/abstract_controller/rendering.rb:40:in process' actionpack (3.0.3) lib/action_controller/metal.rb:138:in
dispatch'
actionpack (3.0.3) lib/action_controller/metal/rack_delegation.rb:14:in dispatch' actionpack (3.0.3) lib/action_controller/metal.rb:178:in
block 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:in
dispatch'
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:in
block 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:in
optimized_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:in
call'
actionpack (3.0.3) lib/action_dispatch/routing/route_set.rb:492:in call' haml (3.0.25) lib/sass/plugin/rack.rb:41:in
call'
warden (1.0.3) lib/warden/manager.rb:35:in block in call' warden (1.0.3) lib/warden/manager.rb:34:in
catch'
warden (1.0.3) lib/warden/manager.rb:34:in call' actionpack (3.0.3) lib/action_dispatch/middleware/best_standards_support.rb:17:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/head.rb:14:in call' rack (1.2.1) lib/rack/methodoverride.rb:24:in
call'
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:in
call'
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:in
call'
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:in
cache'
activerecord (3.0.3) lib/active_record/query_cache.rb:12:in cache' activerecord (3.0.3) lib/active_record/query_cache.rb:31:in
call'
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:in
block 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:in
call'
rack (1.2.1) lib/rack/sendfile.rb:107:in call' actionpack (3.0.3) lib/action_dispatch/middleware/remote_ip.rb:48:in
call'
actionpack (3.0.3) lib/action_dispatch/middleware/show_exceptions.rb:46:in call' railties (3.0.3) lib/rails/rack/logger.rb:13:in
call'
rack (1.2.1) lib/rack/runtime.rb:17:in call' activesupport (3.0.3) lib/active_support/cache/strategy/local_cache.rb:72:in
call'
rack (1.2.1) lib/rack/lock.rb:11:in block in call' <internal:prelude>: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'
+1 Same issue occurring for me too, with ruby 1.8.7 and rails 3 (not using HAML though)
+1 same here
Same here :/
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
as suggested in the accepted answer.
Good luck!
The proper "fix" is to add @map.icons << Cartographer::Gicon.new to your controller :)
@nicinabox doing as you suggest did not affect the problem for me.
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.
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
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
<%= raw Cartographer::Header.new.to_s %> <%= raw @map.to_html %>
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.
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.
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.