view - Rendering a heterogeneous list of objects in rails that includes arrays -


i have collection of attachments, notes, , array of attachments. example

@heterocollection = [attachment, note, note, [attachment, attachment, attachment]] 

in view attempt render collection

<%= render :partial => @heterocollection %> 

but rails chokes saying array of attachments needs implement :to_partial_path

[attachment, ..., attachment] not activemodel-compatible object. must implement :to_partial_path 

if remove array rendering works great calling _attachment.html.erb , _note.html.erb respective records.

is there way implement :to_partial_path on array without monkey patching? or there better solution?

you can create class attachmentarray, extend array , add to_partial_path method it. push attachments new instance of class..


Comments

Popular posts from this blog

php - get table cell data from and place a copy in another table -

javascript - Mootools wait with Fx.Morph start -

php - Navigate throught databse rows -