n8 / multi_fetch_fragments

Multi-fetch Fragments makes rendering and caching a collection of template partials easier and faster.
http://ninjasandrobots.com/rails-faster-partial-rendering-and-caching
MIT License
539 stars 63 forks source link

Rendering a collection may or may not be destructive to the collection #11

Closed tomfakes closed 11 years ago

tomfakes commented 11 years ago

Depending on how many fragments are cached, items are removed from the collection. This leaves the collection with fewer than the items it started with, sometimes as little as zero items.

It would be nice if the collection was not destroyed during the process, so it can be used again, or used for other reasons.

n8 commented 11 years ago

This is a little more dangerous than just that too. If the collection is a has_many collection, I think it may have been possible to actually destroy activerecord objects accidentally. Since Rails aliases the .delete() method which I'm using here on the "collection". I believe cloning the collection should take care of that and the issue you brought up above.