Sha256: 0d75efe7706272f988efaf57a623e12fbd5e543a888b79afb7d4a1dfd96efa86

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

Contents

require_dependency "landable/api_controller"

module Landable
  module Api
    class AuditsController < ApiController
      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

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

      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

      private
        def audit_params
          params[:audit][:flags] ||= []
          params.require(:audit).permit(:id, :approver, :notes, :created_at, flags: [])
        end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
landable-1.13.1 app/controllers/landable/api/audits_controller.rb
landable-1.12.3 app/controllers/landable/api/audits_controller.rb
landable-1.12.2 app/controllers/landable/api/audits_controller.rb
landable-1.12.1 app/controllers/landable/api/audits_controller.rb
landable-1.11.1 app/controllers/landable/api/audits_controller.rb
landable-1.11.0 app/controllers/landable/api/audits_controller.rb
landable-1.10.0.rc2 app/controllers/landable/api/audits_controller.rb
landable-1.10.0.rc1 app/controllers/landable/api/audits_controller.rb
landable-1.9.2 app/controllers/landable/api/audits_controller.rb
landable-1.9.1 app/controllers/landable/api/audits_controller.rb
landable-1.9.0 app/controllers/landable/api/audits_controller.rb
landable-1.9.0.rc2 app/controllers/landable/api/audits_controller.rb