Class: Landable::Api::AuditsController

Inherits:
Landable::ApiController show all
Defined in:
app/controllers/landable/api/audits_controller.rb

Constant Summary

Constants inherited from Landable::ApiController

Landable::ApiController::API_MEDIA_REGEX

Instance Method Summary collapse

Methods inherited from Landable::ApiController

#api_media

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
# File 'app/controllers/landable/api/audits_controller.rb', line 19

def create
  if params[:page_id].present?
    type_id = params[:page_id]
    type    = 'Landable::Page'
  else
    type_id = params[:template_id]
    type    = 'Landable::Template'
  end

  audit = Audit.new audit_params.merge(auditable_id: type_id,
                                       auditable_type: type)
  audit.save!

  respond_with audit, status: :created, location: audit_url(audit)
end

#indexObject



6
7
8
9
10
11
12
13
# File 'app/controllers/landable/api/audits_controller.rb', line 6

def index
  if params[:auditable_id].present?
    audits = Audit.where(auditable_id: params[:auditable_id])
  else
    audits = Audit.order('created_at DESC')
  end
  respond_with audits
end

#showObject



15
16
17
# File 'app/controllers/landable/api/audits_controller.rb', line 15

def show
  respond_with Audit.find(params[:id])
end