2010-09-04 132 views
1

這裏我menu_builder方法在applicationhelper開始下面(在視圖中:<%= menu_builder(@page);%>):的Ruby/Rails content_tag未呈現,正確地(紅寶石1.9.2)

def menu_builder(page) 
    items = [ "home", "faq", "store" ] 
    content = "" 
    items.each do |i| 
    content << content_tag(:a, "#{i.capitalize}", :href => "/#{i}") 
    end 
    return content 
end 

我想渲染鏈接而不是標籤。我應該錯過這裏的一些東西,但我不會找到..

感謝您的幫助!

回答

0

你能解決這個問題是這樣的:

def menu_builder(page) 
    items = [ "home", "faq", "store" ] 
    content = "" 
    items.each do |i| 
    content << content_tag(:a, "#{i.capitalize}", :href => "/#{i}") 
    end 
    content.html_safe 
end 

或修改您的模板是這樣的:

<%= raw menu_builder %> 

使用任何。