2014-06-16 93 views
1

爲什麼所有的content_tags顯示,除了content_tag:我Ruby on Rails的4不顯示content_tag:我

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 

當我使這個幫手,我不看標籤在瀏覽器中的 「i」。 這應該如何工作?

回答

2

這是因爲只返回塊中的最後一條語句。您必須將這兩條語句連接起來,以便將其作爲一個字符串返回:

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