Sorry for wasting your time. this was my fault.
Am Donnerstag, 2. August 2012 18:13:28 UTC+2 schrieb Emily S:
> Hi
> This seems to work for me:
> > db['things'].create_index("name", :unique => true)
> > documents = [{:name => "First"}, {:name => "Second"}]
> > db['things'].insert(documents, :continue_on_error => true, :safe =>
> false)
> *in the mongo shell:*
> > db.things.find()
> { "_id" : ObjectId("501a9cf13005c82ac9000001"), "name" : "First" }
> { "_id" : ObjectId("501a9cf13005c82ac9000002"), "name" : "Second" }
> > documents = [{:name => "First"}, {:name => "Third"}]
> > db['things'].insert(documents, :continue_on_error => true, :safe =>
> false)
> *in the mongo shell:*
> > db.things.find()
> { "_id" : ObjectId("501a9cf13005c82ac9000001"), "name" : "First" }
> { "_id" : ObjectId("501a9cf13005c82ac9000002"), "name" : "Second" }
> { "_id" : ObjectId("501a9d173005c82ac9000004"), "name" : "Third" }
> You shouldn't be getting an exception if you use :safe => false
> What version of Mongoid are you using?
> On Thursday, August 2, 2012 8:40:57 AM UTC-4, Daniel Schlegel wrote:
>> Hi
>> I try to do inserts in monogo with mongoid. unfortunately<http://www.dict.cc/englisch-deutsch/unfortunately.html> the
>> continue_on_error option does not work.
>> Situation:
>> There is an index on :name
>> documents = [{:name => "First"}, {:name => "Second"}]
>> # following line works like expected.
>> MyCollection.collection.insert(documents, :continue_on_error => true,
>> :safe => false)
>> # => First and Second in DB
>> documents = [{:name => "First"}, {:name => "Third"}]
>> MyCollection.collection.insert(documents, :continue_on_error => true,
>> :safe => false)
>> # => Third not in DB.
>> i don't get an exception while inserting, but it seames, that the batch
>> stop it's processing when error occured.
>> Thanks for your help.