I have gmaps4rails working in my rails 4 application with markers for my lcoation, and I would like to include a link in each location marker in each local separate show.
The index action of my space controller is as follows:
def index @spaces = Space.all @hash = Gmaps4rails.build_markers(@spaces) do |space, marker| marker.lat space.latitude marker.lng space.longitude marker.infowindow render_to_string(:partial => "/spaces/infowindow", :locals => { :object=> space}) end end
My private infoindustry:
<%= link_to "Show", space_path(space) %>
My gmaps4rails javascript script in my /index.html space:
<script> handler = Gmaps.build('Google'); handler.buildMap({ provider: {}, internal: {id: 'map'}}, function(){ markers = handler.addMarkers(<%=raw @hash.to_json %>); handler.bounds.extendWith(markers); handler.fitMapToBounds(); }); </script>
When I try to load the space index page, I am greeted with the following error message:
undefined local variable or method `space' for #<#<Class:0x4638c48>:0x5335f20>
According to my previous requests, this seems to be a way to get the link acting in the index, but if there is an alternative solution, I would like to hear it, thanks.
ruby-on-rails ruby-on-rails-4 google-maps gmaps4rails
user3342292
source share