Method: PaperTrail::RecordTrail#record_update

Defined in:
lib/paper_trail/record_trail.rb

#record_update(force:, in_after_callback:, is_touch:) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

paper_trail-association_tracking

Parameters:

  • force (boolean)

    Insert a ‘Version` even if `@record` has not `changed_notably?`.

  • in_after_callback (boolean)

    True when called from an ‘after_update` or `after_touch` callback.

  • is_touch (boolean)

    True when called from an ‘after_touch` callback.

Returns:

    • The created version object, so that plugins can use it, e.g.



104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
# File 'lib/paper_trail/record_trail.rb', line 104

def record_update(force:, in_after_callback:, is_touch:)
  return unless enabled?

  version = build_version_on_update(
    force: force,
    in_after_callback: in_after_callback,
    is_touch: is_touch
  )
  return unless version

  begin
    version.save!
    # Because the version object was created using version_class.new instead
    # of versions_assoc.build?, the association cache is unaware. So, we
    # invalidate the `versions` association cache with `reset`.
    versions.reset
    version
  rescue StandardError => e
    handle_version_errors e, version, :update
  end
end