Rails3 ActionView TagHelper

时间:2013-04-19 13:53:58

标签: ruby-on-rails-3 actionview actionviewhelper

我希望输出为html,如

<div>
  <div/>
  <a/>
</div>

为此我写了ruby代码如下

content_tag :div, '', class: 'handle' do
  content_tag :div, class: icon, style: 'display:inline;' do
    link_to name, edit_path(object), :remote => true
  end
end

这导致<a>在第二个<div>内。怎么做到这一点?

1 个答案:

答案 0 :(得分:0)

您将链接代码放在内部div中,因此在内部呈现。

在你的代码中,内部div之间的代码块会使链接在内部呈现。你需要把它带到外面

content_tag :div, class: icon, style: 'display:inline;' do
  the link here should be outside
end
相关问题