ruby-on-rails-4helpercontent-tag

Ruby on Rails 4 does not display content_tag :i


Why are all the content_tags display except the content_tag :i

  def sign_full_tag(group, obj, name, input_type="text", size="12", popover=true)
    content_tag :div, class: "row" do
      content_tag :div, class: "col-md-" + size do
        content_tag :div, class: "form-group left-inner-addon" + class_for_invalid_input(obj, name) do
          content_tag(:i, "", class: "fa fa-user fa-fw text-muted") # NOT DISPLAY!!!
          group.text_field( name,
                            class: "form-control" + (popover ? " popover-add" : ""),
                            id: name.to_s.gsub("_", "-"),
                            type: input_type,
                            placeholder: "#{t('sign_up.placeholder.' + name.to_s)}",
                            data: { container: "body",
                                    toggle: "popover",
                                    placement: "bottom",
                                    content: (popover ?  "#{t('sign_up.popover.' + name.to_s)}" : nil) })

        end
      end
    end
  end

When I render this helper I don't see tag "i" in my browser. How should this work?


Solution

  • That is because only the last statement in a block is returned. You have to concat the two statements so it is returned as one string:

    content_tag(:div, etc etc) do
      content_tag(:i, "") + group.text_field(name, etc etc)
    end