Class: Pressroom::TagsController

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

Instance Method Summary collapse

Instance Method Details

#destroyObject



24
25
26
27
# File 'app/controllers/pressroom/tags_controller.rb', line 24

def destroy
  @tag.destroy!
  redirect_to tags_path, notice: t("pressroom.tags.destroyed")
end

#editObject



14
# File 'app/controllers/pressroom/tags_controller.rb', line 14

def edit; end

#indexObject



7
8
9
10
11
12
# File 'app/controllers/pressroom/tags_controller.rb', line 7

def index
  @tags = pressroom_scoped(Tag).left_joins(:taggings)
             .group(:id)
             .select("pressroom_tags.*, COUNT(pressroom_taggings.id) AS posts_count")
             .order(:name)
end

#updateObject



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

def update
  if @tag.update(tag_params)
    redirect_to tags_path, notice: t("pressroom.tags.updated")
  else
    render :edit, status: 422
  end
end