1
我使用的軌道2.3.11發電李標籤軌失敗
在我views/layout/application.html.erb
<ul>
<li>1</li>
<li>2</li>
<%= myhelper('t')%>
<li>4</li>
</ul>
我打電話myhelper
方法application_helper.rb
def myhelper(v)
if v
content_tag(:li, link_to("3",/users_path))
end
end
產生li
我已確認myhelper
被調用,但它不會生成li
標記。
請給出建議。
EDIT
我試圖基於在同一個應用程序的輔助從輔助方法的一個接收到的值,其是集合
def myhelper(v)
collections.each_with_index do |c,i|
case c
when 'c'
content_tag(:li, link_to("3", users_path))
end
end
end
def collections
@enabled ||= Setting.get_enabled
end
其中集合接收的陣列以生成L1標籤來自同一幫手的其他幫手方法 - 應用助手
當我評論下面兩行
collections.each_with_index do |c,i|
end
li正在生成。
爲什麼這個輔助方法不getting.Please給點建議
阿魯娜,請註明您的這段代碼的意圖和清理你的代碼。理解你想要完成的事情是很難的。 – edgerunner 2011-05-10 07:09:57
'@ enabled'在'myhelper'中使用時是否包含期望值?按照預期從'collections'返回的值是什麼? 'v'的價值是什麼 - 是真的嗎?你是否嘗試過運行 具有斷點的代碼(即在調試器中),或者可能使用'puts'來試圖找出數據是什麼以及是否調用了所期望的代碼 ?在再次編輯問題之前,請嘗試所有這些事情! – Zabba 2011-05-10 07:42:41
@Zabba - 我嘗試了所有的wat u說..puts isworking insidewhen'c',但是時間標籤不會生成...如果我評論collections.each的東西標籤正在生成 – useranon 2011-05-10 08:00:29