ruby – 哈姆“非法筑巢”问题;如何在同一个标​​签中放置多个代码元素?

前端之家收集整理的这篇文章主要介绍了ruby – 哈姆“非法筑巢”问题;如何在同一个标​​签中放置多个代码元素?前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
- @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",:class => "action edit")
    = link_to("Delete",{:action => "delete",:class => "action delete")

ERROR_MSG:

Illegal nesting: content can’t be both given on the same line as %td and nested within it.

我希望这三个链接显示,编辑和删除 – 在同一个td;我该怎么做?

解决方法

你只需要改变这个:
%td= link_to("Show",:class => "action show") 
  = link_to("Edit",:class => "action edit")
  = link_to("Delete",:class => "action delete")

对此:

%td
  = link_to("Show",:class => "action delete")

你还应该从tr缩进tds.

原文链接:/ruby/266905.html

猜你在找的Ruby相关文章