Ruby on rails Haml Coffee资产模板错误,无法访问主干JS模型?

Ruby on rails Haml Coffee资产模板错误,无法访问主干JS模型?,ruby-on-rails,syntax,coffeescript,haml,hamlc,Ruby On Rails,Syntax,Coffeescript,Haml,Hamlc,我正在Rails 3.2应用程序中使用haml_coffee_资产。以下内容适用于ejs模板: <table> <tr> <th></th> </tr> <% tutorials.each(function(model) { %> <tr> <td><%= model.escape('title') %> </tr> <

我正在Rails 3.2应用程序中使用haml_coffee_资产。以下内容适用于ejs模板:

<table>
  <tr>
    <th></th>
  </tr>
  <% tutorials.each(function(model) { %>
    <tr>
      <td><%= model.escape('title') %>
    </tr>
  <% }); %>
</table>
我得到的只是:

ReferenceError: Can't find variable: model

我终于能够通过以下方式实现这一点:

%table
  %thead
    %tr
      %th Tutorial Name
  %tbody
    - @tutorials.each (model) ->
      %tr
        %td= model.escape('title')

希望这对其他人有帮助

我终于能够通过以下方式实现这一点:

%table
  %thead
    %tr
      %th Tutorial Name
  %tbody
    - @tutorials.each (model) ->
      %tr
        %td= model.escape('title')

希望这对其他人有帮助

既然您提到在GitHub问题上使用主干网,我假设
@tutorials
是主干网集合,您也可以使用以下替代方案:

%table
  %thead
    %tr
      %th Tutorial Name
  %tbody
    - for model in @tutorials.models
      %tr
        %td= model.escape('title')

既然您提到在GitHub问题上使用主干网,我假设
@tutorials
是主干网集合,您也可以使用以下替代方案:

%table
  %thead
    %tr
      %th Tutorial Name
  %tbody
    - for model in @tutorials.models
      %tr
        %td= model.escape('title')

是的,谢谢。我将更新该问题,以包括主干JS。太好了。是的,谢谢。我将更新该问题,以包括主干JS。这太棒了。