2017-08-24 50 views
1

试图在Ruby on Rails上构建应用程序 - 面对haml。 无法理解如何构建嵌套的每个循环 - 总是捕获不同的错误。 这里的代码的例子:如何添加嵌套链接到Haml样机

%table 
    %tr 
    %th Title 
    %th Text 
    - @articles.each do |article| 
    %tr 
     %td article.title 
     %td article.text 
     %td 
     - article.tags.each do |tag| 
     = link_to(tag.tag_name) 

错误:

syntax error, unexpected keyword_ensure, expecting keyword_end 

而且

end-of-input, expecting keyword_end 

如果我删除HAML标签一切正常后。不能understan我在做什么错..

+0

可能在此行'=的link_to(tag.tag_name)'的问题,用'=的link_to(tag.tag_name, “你的道路”'替换) – Vishal

回答

1
%table 
    %tr 
    %th Title 
    %th Text 
    - @articles.each do |article| 
    %tr 
     %td= article.title 
     %td= article.text 
     %td 
     - article.tags.each do |tag| 
      = link_to(tag.tag_name)