seancribbs/ripple — Issue #231: Deleted siblings causes conflict resolver failure
Author: dreverri
Created: 2011-10-27 04:35:32+00:00
State: open

Working with commit id e07b1eab96a069be9e01ce48bbc2e4d04bed2a6d which is the latest as of October 26th.

The below script demonstrates the issue. When a delete causes a sibling the resolver fails to find `s.data['_type]` because `data` is `nil`.

```ruby
require 'rubygems'
require 'ripple'

class Collection
include Ripple::Document

property :items, Array, :default => []

on_conflict do |siblings|
# set-union siblings
self.items = siblings.map(&:items).flatten.uniq
end
end

Collection.bucket.allow_mult = true
collection = Collection.create!
collection1 = Collection.find(collection.key)
collection2 = Collection.find(collection.key)
collection1.items << 1
collection1.save!
collection2.items << 2
collection2.destroy

Collection.find(collection.key)
```

```bash
/Users/dreverri/.rvm/gems/ruby-1.9.2-p136@tmp/bundler/gems/ripple-e07b1eab96a0/ripple/lib/ripple/conflict/resolver.rb:14:in `block (2 levels) in to_proc': undefined method `[]' for nil:NilClass (NoMethodError)
```

Is it advisable to ignore siblings with no data?

```ruby
possible_model_classes = robject.siblings.map { |s| s.data['_type'] rescue nil }.compact.uniq
```