Haml "Illegal Nesting" problem; how to place multiple code elements in the same tag?
开发者_高级运维- @subjects.each do |s|
%tr
%td= s.position
%td= s.name
%td= s.visible ? "Yes" : "No"
%td= s.pages.size
%td= link_to("Show", {:action => "show", :id => s.id}, :class => "action show")
= link_to("Edit", {:action => "edit", :id => s.id}, :class => "action edit")
= link_to("Delete", {:action => "delete", :id => s.id}, :class => "action delete")
error_msg:
Illegal nesting: content can't be both given on the same line as %td and nested within it.
I want those three links--show, edit, and delete--in the same td; how can I do it?
You just need to change this:
%td= link_to("Show", {:action => "show", :id => s.id}, :class => "action show")
= link_to("Edit", {:action => "edit", :id => s.id}, :class => "action edit")
= link_to("Delete", {:action => "delete", :id => s.id}, :class => "action delete")
to this:
%td
= link_to("Show", {:action => "show", :id => s.id}, :class => "action show")
= link_to("Edit", {:action => "edit", :id => s.id}, :class => "action edit")
= link_to("Delete", {:action => "delete", :id => s.id}, :class => "action delete")
You should also indent the td
s from the tr
.
FYI - I ran into this issue too but the culprit was a trailing space after my <td>
, which is content for HAML.
精彩评论