Class: CompletionKit::Api::V1::TagsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/completion_kit/api/v1/tags_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



15
16
17
18
19
20
21
22
# File 'app/controllers/completion_kit/api/v1/tags_controller.rb', line 15

def create
  tag = Tag.new(tag_params)
  if tag.save
    render json: tag, status: :created
  else
    render_validation_errors(tag)
  end
end

#destroyObject



32
33
34
35
# File 'app/controllers/completion_kit/api/v1/tags_controller.rb', line 32

def destroy
  @tag.destroy!
  head :no_content
end

#indexObject



7
8
9
# File 'app/controllers/completion_kit/api/v1/tags_controller.rb', line 7

def index
  render json: paginate(Tag.order(:name))
end

#showObject



11
12
13
# File 'app/controllers/completion_kit/api/v1/tags_controller.rb', line 11

def show
  render json: @tag
end

#updateObject



24
25
26
27
28
29
30
# File 'app/controllers/completion_kit/api/v1/tags_controller.rb', line 24

def update
  if @tag.update(tag_params)
    render json: @tag
  else
    render_validation_errors(@tag)
  end
end