0
不同的模板,我用渲染軌道
<%= render :partial => @list.items%>
一個視圖以顯示該命令稱_item.html.erb。對?
<div class="well">
<%= image_tag item.photo.url(:small) %><br>
<b>Title</b> <%= item.title %><br />
<b>Description</b> <%= item.description %>
</div>
這工作正常。 現在我有一個叫_ilist.html.erb
的其他模板,我需要這些數據。 我嘗試通過添加模板選項來進行渲染。但其他模板不會使用。第一個模板將隨時調用。
<%= render :partial => @list.items, :template => 'items/ilist' %>
是否有任何選項可以調用其他_ilist-template?
感謝您的幫助
謝謝你完蛋了。但現在我得到兩個線路的誤差(爲一個測試我複製item.html.erb)爲# '
Wunsch:<%= item.title %>
Beschreibung:<%= item.description %>
Reservieren
'' 未定義局部變量或方法'項」 <#<類別:0x000000032c0e40>: 0x007fcb645f8390> – amarradi在你的渲染語句中也傳入「:as =>:item」 – cpuguy83
非常感謝,它運行良好。現在我知道這個聲明的含義 – amarradi