Skip to content

Commit

Permalink
Merge pull request #1130 from seanlinsley/remove-save_changes
Browse files Browse the repository at this point in the history
Remove `save_changes`
  • Loading branch information
jaredbeck authored Aug 13, 2018
2 parents 3f9b5be + f3eb770 commit 45456a8
Show file tree
Hide file tree
Showing 7 changed files with 6 additions and 25 deletions.
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.

### 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.

0 comments on commit 45456a8

Please sign in to comment.