Class: PaperTrailUi::ReportsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/paper_trail_ui/reports_controller.rb

Constant Summary collapse

MODEL_NAMES =
PaperTrail::Version.select("DISTINCT item_type").map(&:item_type)
EVENT_TYPES =
PaperTrail::Version.select("DISTINCT event").map(&:event)
ACTOR_NAMES =
PaperTrail::Version.select("DISTINCT whodunnit").map(&:whodunnit)

Instance Method Summary collapse

Instance Method Details

#indexObject



11
12
13
14
15
16
17
# File 'app/controllers/paper_trail_ui/reports_controller.rb', line 11

def index
  @model_names = array_to_filter_hash(MODEL_NAMES)
  @event_names = array_to_filter_hash(EVENT_TYPES)
  @actor_names = array_to_filter_hash(ACTOR_NAMES)
  @query = PaperTrail::Version.search params[:q]
  @versions = @query.result(distinct: true).paginate(page: params[:page], per_page: 100)
end

#showObject



19
20
21
22
# File 'app/controllers/paper_trail_ui/reports_controller.rb', line 19

def show
  @version = PaperTrail::Version.find params[:id]
  @object = YAML.load(@version.object || "---") || {}
end