2011-05-04 68 views
1

我想序列化一個對象,並保存到一個Postgresql數據庫在Ruby中使用ActiveRecord(沒有軌道)。我使用下面的代碼可以這樣做:無法分配內存,NoMemoryError

components.keys.each do |key| 
    cphash = {:training_url => components[key][:training_url], 
       :klass => key.to_s, 
       :component => Marshal::dump(components[key][:component]), 
       :network_id => n} 
    inline = Inline.new(cphash) 
    inline.save! 
    end 

不過,我不斷收到錯誤

failed to allocate memory (NoMemoryError) 

如何解決此得到。我試圖將對象分解成更小的位(我將上面的'每個'中的每一位都保存起來),但是我仍然得到錯誤。任何人都知道什麼給。

回答