Class: Kms::TemplatesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/kms/templates_controller.rb

Instance Method Summary collapse

Methods inherited from ApplicationController

#set_csrf_cookie_for_ng

Instance Method Details

#createObject



8
9
10
11
12
13
14
15
# File 'app/controllers/kms/templates_controller.rb', line 8

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

#destroyObject



31
32
33
34
35
# File 'app/controllers/kms/templates_controller.rb', line 31

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

#indexObject



4
5
6
# File 'app/controllers/kms/templates_controller.rb', line 4

def index
  render json: Template.all.to_json
end

#showObject



26
27
28
29
# File 'app/controllers/kms/templates_controller.rb', line 26

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

#updateObject



17
18
19
20
21
22
23
24
# File 'app/controllers/kms/templates_controller.rb', line 17

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