From 94fe0b4049d903b6f14caac4be34cbe33fa5f4a2 Mon Sep 17 00:00:00 2001 From: Raphael Date: Tue, 14 Dec 2010 21:54:18 -0800 Subject: [PATCH] Do the update in JS --- lib/tasks/migrations.rake | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/tasks/migrations.rake b/lib/tasks/migrations.rake index 6c86bd113..4965c6793 100644 --- a/lib/tasks/migrations.rake +++ b/lib/tasks/migrations.rake @@ -30,9 +30,9 @@ namespace :migrations do task :contacts_as_requests do require File.join(Rails.root,"config/environment") puts "Migrating contacts..." - Contact.find_each(:pending => nil){|contact| - contact.pending = false; contact.save - } + MongoMapper.database.eval(' + db.contacts.find({pending : null}).forEach(function(contact){ + db.contacts.update({"_id" : contact["_id"]}, {"$set" : {"pending" : false}}); });') puts "Deleting stale requests..." Request.find_each(:sent => true){|request| request.delete