Skip to content
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

track_associations= warning #1150

Merged
merged 1 commit into from
Sep 1, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,8 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).

### Fixed

- None
- When PT-AT is not loaded, and someone sets `track_associations = false`,
it should `warn`, not `raise`.

## 10.0.0 (2018-09-01)

Expand Down
18 changes: 15 additions & 3 deletions lib/paper_trail/config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ class Config

E_PT_AT_REMOVED = <<-EOS.squish
Association Tracking for PaperTrail has been extracted to a seperate gem.
Please add `paper_trail-association_tracking` to your Gemfile.
To use it, please add `paper_trail-association_tracking` to your Gemfile.
If you don't use it (most people don't, that's the default) and you set
`track_associations = false` somewhere (probably a rails initializer) you
can remove that line now.
EOS

attr_accessor(
Expand Down Expand Up @@ -47,10 +50,19 @@ def enabled=(enable)
# because there is no known use case where someone would want to rescue
# this. If we think of such a use case in the future we can revisit this
# decision.
def track_associations=(_)
raise E_PT_AT_REMOVED
#
# @override If PT-AT is `require`d, it will replace this method with its
# own implementation.
def track_associations=(value)
if value
raise E_PT_AT_REMOVED
else
::Kernel.warn(E_PT_AT_REMOVED)
end
end

# @override If PT-AT is `require`d, it will replace this method with its
# own implementation.
def track_associations?
raise E_PT_AT_REMOVED
end
Expand Down