Sha256: 04dc57bf009679b4c63df912d7dc007f6cf4adb017a8a24c9d15fe7f24d4aaea

Contents?: true

Size: 1.04 KB

Versions: 8

Compression:

Stored size: 1.04 KB

Contents

module Kms
  class TemplatesController < ApplicationController
    load_and_authorize_resource
    def index
      render json: Template.all.to_json
    end

    def create
      @template = Template.new(template_params)
      if @template.save
        render json: @template.to_json
      else
        render json: @template.to_json(methods: :errors), status: :unprocessable_entity
      end
    end

    def update
      @template = Template.find(params[:id])
      if @template.update_attributes(template_params)
        render json: @template.to_json
      else
        render json: @template.to_json(methods: :errors), status: :unprocessable_entity
      end
    end

    def show
      @template = Template.find(params[:id])
      render json: @template.to_json
    end

    def destroy
      @template = Template.find(params[:id])
      @template.destroy
      render json: @template.to_json
    end

    protected

    def template_params
      params.require(:template).permit(:name,:content)
    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
kms-0.9.0 app/controllers/kms/templates_controller.rb
kms-0.8.0 app/controllers/kms/templates_controller.rb
kms-0.7.0 app/controllers/kms/templates_controller.rb
kms-0.6.0 app/controllers/kms/templates_controller.rb
kms-0.5.0 app/controllers/kms/templates_controller.rb
kms-0.4.2 app/controllers/kms/templates_controller.rb
kms-0.4.1 app/controllers/kms/templates_controller.rb
kms-0.4.0 app/controllers/kms/templates_controller.rb