mongoid/mongoid — Issue #1639: Disabling Mongoid observers not working
Author: weppos
Created: 2012-01-24 16:06:55+00:00
State: open

This ticket is related to #1519.

According to `ActiveModel` documentation, the following call should disable all observers for all models.

Mongoid.observers.disable :all

In fact, this call works with `ActiveRecord::Base.observers.disable :all`. However, it doesn't work with Mongoid 2.4.1. You can reproduce it using the code posted in #1581.

```ruby
class A
include Mongoid::Document
field :name
end

class AObserver < Mongoid::Observer
def around_update(a)
puts "before"
yield
puts "after"
end
end

A.delete_all
AObserver.instance

a = A.create :name => 'fake'

Mongoid.observers.disable :all
a.update_attribute :name, 'test1'
# => before
# => after

A.observers.disable :all
a.update_attribute :name, 'test 2'
# no output
```