To do this, use the Mongo ruby driver. You can pass an array of hashes to a method insertto create several documents at once (more about this discussion of google groups ). Mongoid facilitates access to the ruby driver.
The code looks something like this:
user_list = twitter_accounts.map do |account|
{ 'name' => account.name,
'username' => account.username
}
end
Mongoid.master['twitter_users'].insert(user_list)
source
share