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
太棒了!没问题! –