Class: TagSetsController

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

Instance Method Summary collapse

Methods inherited from ApplicationController

#dashboard, #keyboard_tools, #upload

Instance Method Details

#globalObject



11
12
13
14
15
# File 'app/controllers/tag_sets_controller.rb', line 11

def global
  @tag_sets = TagSet.unscoped.all.includes(:community)
  @counts = @tag_sets.left_joins(:tags).group(:id).count(Arel.sql('tags.id'))
  render :index
end

#indexObject



6
7
8
9
# File 'app/controllers/tag_sets_controller.rb', line 6

def index
  @tag_sets = TagSet.all.includes(:community)
  @counts = @tag_sets.left_joins(:tags).group(:id).count(Arel.sql('tags.id'))
end

#showObject



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

def show
  respond_to do |format|
    format.json do
      render json: @tag_set
    end
  end
end

#updateObject



25
26
27
28
29
30
31
32
33
34
# File 'app/controllers/tag_sets_controller.rb', line 25

def update
  before = @tag_set.attributes_print
  if @tag_set.update(name: params[:name])
    render json: { tag_set: @tag_set, status: 'success' }
    AuditLog.admin_audit(event_type: 'tag_set_update', related: @tag_set, user: current_user,
                         comment: "from <<TagSet #{before}>>\nto <<TagSet #{@tag_set.attributes_print}>>")
  else
    render json: { tag_set: @tag_set, status: 'failed' }, status: :internal_server_error
  end
end