Class: CompletionKit::TagsController

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

Instance Method Summary collapse

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
# File 'app/controllers/completion_kit/tags_controller.rb', line 18

def create
  @tag = Tag.new(tag_params)
  if @tag.save
    redirect_to tags_path, notice: "Tag was successfully created."
  else
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



35
36
37
38
# File 'app/controllers/completion_kit/tags_controller.rb', line 35

def destroy
  @tag.destroy
  redirect_to tags_path, notice: "Tag was successfully destroyed."
end

#editObject



15
16
# File 'app/controllers/completion_kit/tags_controller.rb', line 15

def edit
end

#indexObject



5
6
7
8
9
# File 'app/controllers/completion_kit/tags_controller.rb', line 5

def index
  @tags = Tag.order(:name)
  @tagging_counts = Tagging.group(:tag_id).count
  @tagging_by_type = Tagging.group(:tag_id, :taggable_type).count
end

#newObject



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

def new
  @tag = Tag.new(color: Tag::COLORS.sample)
end

#updateObject



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

def update
  if @tag.update(tag_params)
    redirect_to tags_path, notice: "Tag was successfully updated."
  else
    render :edit, status: :unprocessable_entity
  end
end