我有附件、注释和附件数组的集合。例如
@heteroCollection = [Attachment, Note, Note, [Attachment, Attachment, Attachment]]
在我看来,我试图呈现这个集合
<%= render :partial => @heteroCollection %>
但是 rails 窒息说附件阵列需要实施:to_partial_path
[Attachment, ..., Attachment] is not an ActiveModel-compatible object. It must implement :to_partial_path
如果我删除数组,则渲染效果很好_attachment.html.erb
,_note.html.erb
适用于相应的记录。
有没有办法在没有猴子补丁的情况下在 Array 上实现 :to_partial_path ?还是有其他更好的解决方案?