Class: Api::V1::TagFollowingsController

Inherits:
BaseController show all
Defined in:
app/controllers/api/v1/tag_followings_controller.rb

Instance Attribute Summary

Attributes included from OpenidConnect::ProtectedResourceEndpoint

#current_token

Instance Method Summary collapse

Methods included from OpenidConnect::ProtectedResourceEndpoint

#access_token?, #require_access_token

Instance Method Details

#createObject


18
19
20
21
22
23
24
25
# File 'app/controllers/api/v1/tag_followings_controller.rb', line 18

def create
  tag_followings_service.create(params.require(:name))
  head :no_content
rescue TagFollowingService::DuplicateTag
  render_error 409, "Already following this tag"
rescue StandardError
  render_error 422, "Failed to process the tag followings request"
end

#destroyObject


27
28
29
30
31
32
# File 'app/controllers/api/v1/tag_followings_controller.rb', line 27

def destroy
  tag_followings_service.destroy_by_name(params.require(:id))
  head :no_content
rescue ActiveRecord::RecordNotFound
  render_error 410, "Not following this tag"
end

#indexObject


14
15
16
# File 'app/controllers/api/v1/tag_followings_controller.rb', line 14

def index
  render json: tag_followings_service.index.pluck(:name)
end