1

我有这段代码可以在页面上显示多个地图:

.row
  .span12
    - counter = 1
    - @users.each do |user|
      - map_visits = user.visits.to_gmaps4rails
        - unless map_visits.blank?
          .span3
            %div{ id: "container_#{counter}" }
              %div{ id: "map_#{counter}" }
                = gmaps(map_options: { zoom: 6, container_id: "container_#{counter}", id: "map_#{counter}" }, markers: { data: map_visits } )
                - counter += counter

它返回一个错误“语法错误,意外的keyword_ensure,期待$end”,但我真的不知道这里出了什么问题。Better_errors gem 显示代码中 3 个“container_#{counter}”项的错误。有任何想法吗?

4

1 回答 1

0

你有一些不必要的缩进,行 - unless map_visits.blank?(及其后面的行)不应该缩进:

- map_visits = user.visits.to_gmaps4rails
- unless map_visits.blank?
  .span3
    ...
于 2013-06-28T11:39:02.327 回答