Class: SimpleHistory::HistoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/simple_history/histories_controller.rb

Instance Method Summary collapse

Instance Method Details

#indexObject



3
4
5
6
7
8
9
10
11
12
# File 'app/controllers/simple_history/histories_controller.rb', line 3

def index
  if params["record_type"].present? && params["record_id"].present?
    @histories = History.where(record_type: params["record_type"], record_id: params["record_id"]).order(created_at: :desc)
  elsif params["record_type"].present?
    @histories = History.where(record_type: params["record_type"]).order(created_at: :desc)
  else
    @histories = History.all.order(created_at: :desc)
  end
  @record_types = History.pluck(:record_type).uniq
end

#showObject



14
15
16
# File 'app/controllers/simple_history/histories_controller.rb', line 14

def show
  @history = History.find(params[:id])
end