mirror of
https://github.com/paper-trail-gem/paper_trail.git
synced 2022-11-09 11:33:19 -05:00
Remove without_versioning
documentation from README (removed in #1132)
Removed duplicate 'per class' documentation Added comment RE removed `without_versioning` method (and it's alternatives)
This commit is contained in:
parent
e527173899
commit
a9141798c5
1 changed files with 24 additions and 34 deletions
58
README.md
58
README.md
|
@ -492,16 +492,30 @@ PaperTrail.request(enabled: false) do
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
This should satisfy most needs. In the rare case that you need to disable
|
or,
|
||||||
versioning for one model while keeping versioning enabled for other models, use:
|
|
||||||
|
```ruby
|
||||||
|
PaperTrail.request.enabled = false
|
||||||
|
# no versions created
|
||||||
|
PaperTrail.request.enabled = true
|
||||||
|
```
|
||||||
|
|
||||||
|
#### Per Class
|
||||||
|
|
||||||
|
In the rare case that you need to disable versioning for one model while
|
||||||
|
keeping versioning enabled for other models, use:
|
||||||
|
|
||||||
```ruby
|
```ruby
|
||||||
PaperTrail.request.disable_model(Banana)
|
PaperTrail.request.disable_model(Banana)
|
||||||
# ...
|
# changes to Banana model do not create versions,
|
||||||
|
# but eg. changes to Kiwi model do.
|
||||||
PaperTrail.request.enable_model(Banana)
|
PaperTrail.request.enable_model(Banana)
|
||||||
PaperTrail.request.enabled_for_model?(Banana) # => true
|
PaperTrail.request.enabled_for_model?(Banana) # => true
|
||||||
```
|
```
|
||||||
|
|
||||||
|
This setting, as with all `PaperTrail.request` settings, affects only the
|
||||||
|
current request, not all threads.
|
||||||
|
|
||||||
For this rare use case, there is no convenient way to pass a block.
|
For this rare use case, there is no convenient way to pass a block.
|
||||||
|
|
||||||
##### In a Rails Controller Callback (Not Recommended)
|
##### In a Rails Controller Callback (Not Recommended)
|
||||||
|
@ -519,41 +533,17 @@ class ApplicationController < ActionController::Base
|
||||||
end
|
end
|
||||||
```
|
```
|
||||||
|
|
||||||
Because you are unable to controll the order of callback execution, this
|
Because you are unable to control the order of callback execution, this
|
||||||
technique is not recommended, but is preserved for backwards compatability.
|
technique is not recommended, but is preserved for backwards compatibility.
|
||||||
|
|
||||||
It would be better to install your own callback and use
|
It would be better to install your own callback and use
|
||||||
`PaperTrail.request.enabled=` as you see fit.
|
`PaperTrail.request.enabled=` as you see fit.
|
||||||
|
|
||||||
#### Per Class
|
#### Per Method (Removed)
|
||||||
|
|
||||||
```ruby
|
The `widget.paper_trail.without_versioning` method was removed in v10, without
|
||||||
PaperTrail.request.enable_model(Widget)
|
an exact replacement. To disable versioning, use the [Per Class](#per-class) or
|
||||||
PaperTrail.request.disable_model(Widget)
|
[Per HTTP Request](#per-http-request) methods.
|
||||||
```
|
|
||||||
|
|
||||||
This setting, as with all `PaperTrail.request` settings, affects only the
|
|
||||||
current request, not all threads.
|
|
||||||
|
|
||||||
#### Per Method
|
|
||||||
|
|
||||||
You can call a method without creating a new version using `without_versioning`.
|
|
||||||
It takes either a method name as a symbol:
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
@widget.paper_trail.without_versioning :destroy
|
|
||||||
```
|
|
||||||
|
|
||||||
Or a block:
|
|
||||||
|
|
||||||
```ruby
|
|
||||||
@widget.paper_trail.without_versioning do
|
|
||||||
@widget.update_attributes name: 'Ford'
|
|
||||||
end
|
|
||||||
```
|
|
||||||
|
|
||||||
During `without_versioning`, PaperTrail is disabled for the whole model
|
|
||||||
(e.g. `Widget`), not just for the instance (e.g. `@widget`).
|
|
||||||
|
|
||||||
### 2.e. Limiting the Number of Versions Created
|
### 2.e. Limiting the Number of Versions Created
|
||||||
|
|
||||||
|
@ -869,7 +859,7 @@ use it to fix a rare issue with reification of STI subclasses.
|
||||||
add_column :versions, :item_subtype, :string, null: true
|
add_column :versions, :item_subtype, :string, null: true
|
||||||
```
|
```
|
||||||
|
|
||||||
So, if you use PT-AT and STI, the addition of this colulmn is recommended.
|
So, if you use PT-AT and STI, the addition of this column is recommended.
|
||||||
|
|
||||||
- https://github.com/paper-trail-gem/paper_trail/issues/594
|
- https://github.com/paper-trail-gem/paper_trail/issues/594
|
||||||
- https://github.com/paper-trail-gem/paper_trail/pull/1143
|
- https://github.com/paper-trail-gem/paper_trail/pull/1143
|
||||||
|
|
Loading…
Reference in a new issue