-
Notifications
You must be signed in to change notification settings - Fork 130
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Improve disable
and disable_tracking
, add their inverses
#240
Changes from 3 commits
3a44021
15466d8
52bac23
a2998df
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's alias Comment.disable_tracking! or Comment.disable_tracking do
...
end |
||
|
||
# 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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as the above, |
||
|
||
# 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. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Split in two lines with the same PR. There are two changes here.