Class: PaperTrailHistory::ModelsController

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

Overview

Controller for managing trackable model operations and displaying version histories

Instance Method Summary collapse

Instance Method Details

#indexObject



6
7
8
# File 'app/controllers/paper_trail_history/models_controller.rb', line 6

def index
  @trackable_models = TrackableModel.all_with_counts
end

#showObject



10
11
12
13
14
15
16
17
18
19
20
21
# File 'app/controllers/paper_trail_history/models_controller.rb', line 10

def show
  @trackable_model = TrackableModel.find(params[:name])

  unless @trackable_model
    redirect_to models_path, alert: t('paper_trail_history.errors.model_not_found', model_name: params[:name])
    return
  end

  @recent_versions = VersionDecorator.decorate_collection(
    @trackable_model.recent_versions(20)
  )
end

#versionsObject



23
24
25
26
27
28
29
# File 'app/controllers/paper_trail_history/models_controller.rb', line 23

def versions
  @trackable_model = find_trackable_model_or_redirect
  return unless @trackable_model

  load_versions_data
  load_filter_options
end