0

我的匹配索引中有这段代码:

<table>
<% @matches.each do |match| %>
  <tr>
    <td><%= match.team_a %></td>
    <td><%= match.team_b %></td>
    <td><%= match.score_a %> - <%= match.score_b %></td>
    <td><%= match.field %></td>
    <%= render "shared/asterisk_message", :target => [match.team_b, match.team_a] %>
<% end %>
</table>

我想将渲染的asterisk_message 移到表之外,但这意味着将它放在 之后<% end %>,这显然给了我这个错误:

#<#:0xb6da40d8> 的未定义局部变量或方法“匹配”

我该如何解决?

4

1 回答 1

1

尝试:

<table>
    <% @matches.each do |match| %>
      <tr>
        <td><%= match.team_a %></td>
        <td><%= match.team_b %></td>
        <td><%= match.score_a %> - <%= match.score_b %></td>
        <td><%= match.field %></td>
        <%= render "shared/asterisk_message", :target => [match.team_b, match.team_a] %>
    <% end %>
    </table>

<% @matches.each do |match| %>
<%= render "shared/asterisk_message", :target => [match.team_b, match.team_a] %>
<% end %>
于 2013-01-22T15:02:20.187 回答