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

Remove save_changes #1130

Merged
merged 1 commit into from
Aug 13, 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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,10 @@ recommendations of [keepachangelog.com](http://keepachangelog.com/).
- Removed `touch_with_version`, was deprecated in 9.0.0
- [#1121](https://github.com/paper-trail-gem/paper_trail/issues/1121) -
`touch` now always inserts `null` in `object_changes`.
- [#1099](https://github.com/paper-trail-gem/paper_trail/issues/1099) -
Removed `save_changes`. For those wanting to save space, it's more effective
to drop the `object` column. To preserve the old behavior you can add an
`object_changes_adapter`.

### Added

Expand Down
4 changes: 0 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -723,10 +723,6 @@ For diffing two ActiveRecord objects:
* [activerecord-diff][23]: rather like ActiveRecord::Dirty but also allows you
to specify which columns to compare.

If you want to selectively record changes for some models but not others you
can opt out of recording changes by passing `save_changes: false` to your
`has_paper_trail` method declaration.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job getting the docs also

### 3.d. Deleting Old Versions

Over time your `versions` table will grow to an unwieldy size. Because each
Expand Down
3 changes: 1 addition & 2 deletions lib/paper_trail/events/base.rb
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@ def recordable_object_changes(changes)
#
# @api private
def record_object_changes?
@record.paper_trail_options[:save_changes] &&
@record.class.paper_trail.version_class.column_names.include?("object_changes")
@record.class.paper_trail.version_class.column_names.include?("object_changes")
end

# Returns a boolean indicating whether to store the original object during save.
Expand Down
2 changes: 0 additions & 2 deletions lib/paper_trail/has_paper_trail.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ module ClassMethods
# is `:versions`.
# - :version - The name to use for the method which returns the version
# the instance was reified from. Default is `:version`.
# - :save_changes - Whether or not to save changes to the object_changes
# column if it exists. Default is true
# - :join_tables - If the model has a has_and_belongs_to_many relation
# with an unpapertrailed model, passing the name of the association to
# the join_tables option will paper trail the join table but not save
Expand Down
3 changes: 0 additions & 3 deletions lib/paper_trail/model_config.rb
Original file line number Diff line number Diff line change
Expand Up @@ -231,9 +231,6 @@ def setup_options(options)
end

@model_class.paper_trail_options[:meta] ||= {}
if @model_class.paper_trail_options[:save_changes].nil?
@model_class.paper_trail_options[:save_changes] = true
end
end
end
end
2 changes: 1 addition & 1 deletion spec/dummy_app/app/models/thing.rb
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# frozen_string_literal: true

class Thing < ActiveRecord::Base
has_paper_trail save_changes: false
has_paper_trail

if ActiveRecord.gem_version >= Gem::Version.new("5.0")
belongs_to :person, optional: true
Expand Down
13 changes: 0 additions & 13 deletions spec/models/thing_spec.rb

This file was deleted.