Skip to content

Commit

Permalink
Update README with disable and disable_tracking improvements, add…
Browse files Browse the repository at this point in the history
… their inverses
  • Loading branch information
cgriego committed Apr 14, 2020
1 parent 15466d8 commit 52bac23
Showing 1 changed file with 24 additions and 1 deletion.
25 changes: 24 additions & 1 deletion README.md
Expand Up @@ -149,11 +149,34 @@ Comment.disable_tracking do
comment.update_attributes(:title => "Test 3")
end

# globally disable all history tracking
# disable tracking for comments by default
Comment.disable_tracking

# enable tracking for comments within a block
Comment.enable_tracking do
comment.update_attributes(:title => "Test 3")
end

# renable tracking for comments by default
Comment.enable_tracking

# globally disable all history tracking within a block
Mongoid::History.disable do
comment.update_attributes(:title => "Test 3")
user.update_attributes(:name => "Eddie Van Halen")
end

# globally disable all history tracking by default
Mongoid::History.disable

# globally enable all history tracking within a block
Mongoid::History.enable do
comment.update_attributes(:title => "Test 3")
user.update_attributes(:name => "Eddie Van Halen")
end

# globally renable all history tracking by default
Mongoid::History.enable
```

You may want to track changes on all fields.
Expand Down

0 comments on commit 52bac23

Please sign in to comment.