Class: PaperTrailHistory::VersionsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/paper_trail_history/versions_controller.rb

Overview

Controller for managing version operations like viewing and restoring specific versions

Instance Method Summary collapse

Methods inherited from ApplicationController

warn_about_unconfigured_access

Instance Method Details

#restoreObject



16
17
18
19
20
21
22
23
24
25
# File 'app/controllers/paper_trail_history/versions_controller.rb', line 16

def restore
  result = VersionService.restore_version(@version)

  if result[:success]
    redirect_back_or_to(version_path(@version, model_name: @version.item_type), notice: result[:message])
  else
    redirect_back_or_to(version_path(@version, model_name: @version.item_type),
                        alert: t('paper_trail_history.errors.restore_failed', error: result[:error]))
  end
end

#showObject



9
10
11
12
13
14
# File 'app/controllers/paper_trail_history/versions_controller.rb', line 9

def show
  @trackable_model = TrackableModel.find(@version.item_type)
  return redirect_to_missing_model unless @trackable_model

  @decorated_version = VersionDecorator.decorate(@version)
end