0
我有一組附件,註釋和附件數組。例如在包含陣列的導軌中呈現異構對象列表
@heteroCollection = [Attachment, Note, Note, [Attachment, Attachment, Attachment]]
在我看來,我試圖使這個集合
<%= render :partial => @heteroCollection %>
但軌道嗆說附件的陣列需要實現:to_partial_path
[Attachment, ..., Attachment] is not an ActiveModel-compatible object. It must implement :to_partial_path
如果我刪除陣列對於相應的記錄,渲染效果很好,呼叫_attachment.html.erb
和_note.html.erb
。
有沒有一種方法來實現:to_partial_path數組沒有猴子修補?還是有另一個更好的解決方案?
好主意!我會給它一個鏡頭。 – grossadamm
它的工作原理,謝謝...我會標記它回答,當它讓我。 – grossadamm
太棒了!沒問題! –