# AR\_Extension help

**URL:** <https://www.ruby-forum.com/t/ar-extension-help/177400>\
**Category:** Ruby\
**Created:** [October 16, 2009, 11:53am UTC](https://www.ruby-forum.com/t/ar-extension-help/177400 "2009-10-16T11:53:25Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![kingston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e8c25b/32.png) [@kingston](https://www.ruby-forum.com/u/kingston)\
**Post date:** [October 16, 2009, 11:53am UTC](https://www.ruby-forum.com/t/ar-extension-help/177400/1 "2009-10-16T11:53:25Z")

</div>

I using ar\_extensions for mass insertions I found it very effective

all I want is to cache the inserted records into the variable when they  
are inserted

something of this kind for a single insert command

cached\_record = []  
records.each\_with\_index do |record,i|  
cached\_record \<\< Record.create(:name =\> record,:value =\> i)  
end

so that I don’t have to look up in database for the inserted records as  
I have them on the fly

is the above kind of code can used with ar\_extenions or any other  
options

so that when I do  
“Record.import()” for mass insertion of the records. The records can  
also be cache into a variable

same as above

Note : I don’t want to lookup in database as my database is huge  
crossing over five million records so looking up for the inserted  
records  
e.g  
cached\_record \<\< Record.all  
that a long amount of time close to 20 min

and I don’t need that

Thanks anyway

---

<div class="post-metadata">

**Author:** ![kingston](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/e8c25b/32.png) [@kingston](https://www.ruby-forum.com/u/kingston)\
**Post date:** [October 16, 2009, 5:37pm UTC](https://www.ruby-forum.com/t/ar-extension-help/177400/2 "2009-10-16T17:37:51Z")

</div>

> so that when I do  
> “Record.import()” for mass insertion of the records. The records can  
> also be cache into a variable

Perhaps you can save them to your cache before passing them into the  
import call? (sorry, don’t use ar\_extensions all that much).  
-r
