Class: Admin::TagsController

Inherits:
BaseController show all
Defined in:
app/controllers/admin/tags_controller.rb

Instance Method Summary collapse

Methods included from BlogHelper

#blog_base_url, #this_blog

Instance Method Details

#createObject



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

def create
  @tag = this_blog.tags.new(tag_params)

  if @tag.save
    flash[:notice] = I18n.t("admin.base.successfully_created",
                            name: PostType.model_name.human)
    redirect_to admin_tags_url
  else
    fetch_tags
    render :index
  end
end

#destroyObject



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

def destroy
  destroy_a(Tag)
end

#editObject



11
# File 'app/controllers/admin/tags_controller.rb', line 11

def edit; end

#indexObject



7
8
9
# File 'app/controllers/admin/tags_controller.rb', line 7

def index
  @tag = Tag.new
end

#updateObject



26
27
28
29
30
31
32
33
34
35
# File 'app/controllers/admin/tags_controller.rb', line 26

def update
  old_name = @tag.name
  if @tag.update(tag_params)
    # TODO: Check whether these redirects are useful or ignored.
    Redirect.create(from_path: "/tag/#{old_name}", to_path: @tag.permalink_url(nil, true))
    redirect_to admin_tags_url, notice: I18n.t("admin.tags.edit.success")
  else
    render :edit
  end
end