Class: Blog::TagsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/blog/tags_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /tags



16
17
18
19
20
21
22
23
24
# File 'app/controllers/blog/tags_controller.rb', line 16

def create
  @tag = Tag.new(tag_params)

  if @tag.save
    render json: @tag, status: :created
  else
    render json: @tag.errors, status: :unprocessable_entity
  end
end

#destroyObject

DELETE /tags/1



36
37
38
39
# File 'app/controllers/blog/tags_controller.rb', line 36

def destroy
  @tag.destroy
  render json: { success: true }
end

#indexObject

GET /tags



6
7
8
# File 'app/controllers/blog/tags_controller.rb', line 6

def index
  render json: Tag.all
end

#showObject

GET /tags/1



11
12
13
# File 'app/controllers/blog/tags_controller.rb', line 11

def show
  render json: @tag
end

#updateObject

PATCH/PUT /tags/1



27
28
29
30
31
32
33
# File 'app/controllers/blog/tags_controller.rb', line 27

def update
  if @tag.update(tag_params)
    render json: @tag
  else
    render json: @tag.errors, status: :unprocessable_entity
  end
end