Rails helper,concat content_tag

时间:2014-12-17 18:03:59

标签: ruby-on-rails ruby helper

我试图在我的视图中使用帮助器渲染div,这很简单。

def render_form_steps_header
    content_tag :div , class: 'col-xs-3 bs-wizard-step complete' do
        content_tag :div, class: 'text-center bs-wizard-stepnum' do
            "Step 1"
        end

        content_tag :div, class: 'progress' do
            content_tag :div, nil, class: 'progress-bar'
        end
        link_to "", "", :class => "bs-wizard-dot"
    end

但似乎只是采取最后一行" link_to",如果我删除该行,它工作正常并按预期返回div。有什么想法吗?

1 个答案:

答案 0 :(得分:0)

已修复:

def render_form_steps_header
content_tag :div , class: 'col-xs-3 bs-wizard-step complete' do
  str = content_tag :div, class: 'text-center bs-wizard-stepnum' do
    "Step 1"
  end
  str += content_tag :div, class: 'progress' do
    content_tag :div, nil, class: 'progress-bar'
  end

  str += link_to "", "", :class => "bs-wizard-dot"
end