2017-08-24 28 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)