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



11
12
13
14
15
16
17
18
19
20
# File 'app/controllers/admin/tags_controller.rb', line 11

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

  if @tag.save
    redirect_to admin_tags_url, notice: 'Tag was successfully created.'
  else
    fetch_tags
    render :index
  end
end

#destroyObject



33
34
35
# File 'app/controllers/admin/tags_controller.rb', line 33

def destroy
  destroy_a(Tag)
end

#editObject



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

def edit; end

#indexObject



5
6
7
# File 'app/controllers/admin/tags_controller.rb', line 5

def index
  @tag = Tag.new
end

#updateObject



22
23
24
25
26
27
28
29
30
31
# File 'app/controllers/admin/tags_controller.rb', line 22

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