什麼是約定使用部分列出的項目,VS部分節目顯示/編輯/新表單部分與列表部分的Rails約定?
例如在概述一會想做的事: [應用程序/零件/] (件/ index.html.erb)
<h1> Parts and stuff! </h1>
<table>
# headers and such
<%= render :partial => @parts %>
</table>
# calls _part to make a list, usually the 3 most important things
然後我們有一些像 [應用程序/零件/新] (件/ new.html.erb)
# what is the convention for the partial here?
# Said partial would be used for new/edit
我知道你可以指定render:partial =>「path/to/partial」,但是我希望基於資源的路由通過一些常規的名字來獲得一個部分。
我不同意。最明顯的相反點是_partial.html.foo。獲得rails來渲染一個不以'_'開頭的部分是相當多的額外工作。同樣,你可以使用諸如render的shorthands:partial => object.has_many_relations。它會查找「_has_many_relation.html」 – EnabrenTane 2012-01-23 16:36:18