Class: Kms::SnippetsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#set_csrf_cookie_for_ng

Instance Method Details

#createObject



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

def create
  @snippet = Snippet.new(snippet_params)
  if @snippet.save
    head :no_content
  else
    render json: {errors: @snippet.errors}.to_json, status: :unprocessable_entity
  end
end

#destroyObject



32
33
34
35
36
# File 'app/controllers/kms/snippets_controller.rb', line 32

def destroy
  @snippet = Snippet.find(params[:id])
  @snippet.destroy
  head :no_content
end

#indexObject



5
6
7
# File 'app/controllers/kms/snippets_controller.rb', line 5

def index
  render json: Snippet.all, root: false
end

#showObject



27
28
29
30
# File 'app/controllers/kms/snippets_controller.rb', line 27

def show
  @snippet = Snippet.find(params[:id])
  render json: @snippet, root: false
end

#updateObject



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

def update
  @snippet = Snippet.find(params[:id])
  if @snippet.update(snippet_params)
    head :no_content
  else
    render json: {errors: @snippet.errors}.to_json, status: :unprocessable_entity
  end
end