Merge pull request #808 from md5/backport-683
Warn if paper_trail_on_destroy(:after) is combined with ActiveRecord belongs_to_required_by_default
This commit is contained in:
commit
1359b52e13
|
@ -1,3 +1,11 @@
|
|||
## 4.2.0 (Unreleased)
|
||||
|
||||
### Added
|
||||
|
||||
- [#808](https://github.com/airblade/paper_trail/pull/808) -
|
||||
Warn when destroy callback is set to :after with ActiveRecord 5
|
||||
option `belongs_to_required_by_default` set to `true`.
|
||||
|
||||
## 4.1.0
|
||||
|
||||
### Breaking Changes
|
||||
|
|
|
@ -120,9 +120,18 @@ module PaperTrail
|
|||
fail ArgumentError, 'recording order can only be "after" or "before"'
|
||||
end
|
||||
|
||||
send "#{recording_order}_destroy",
|
||||
:record_destroy,
|
||||
:if => :save_version?
|
||||
if recording_order.to_s == 'after' and
|
||||
Gem::Version.new(ActiveRecord::VERSION::STRING).release >= Gem::Version.new("5")
|
||||
if ::ActiveRecord::Base.belongs_to_required_by_default
|
||||
::ActiveSupport::Deprecation.warn(
|
||||
"paper_trail_on_destroy(:after) is incompatible with ActiveRecord " +
|
||||
"belongs_to_required_by_default and has no effect. Please use :before " +
|
||||
"or disable belongs_to_required_by_default."
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
send "#{recording_order}_destroy", :record_destroy, :if => :save_version?
|
||||
|
||||
return if paper_trail_options[:on].include?(:destroy)
|
||||
paper_trail_options[:on] << :destroy
|
||||
|
|
Loading…
Reference in New Issue