Class: Spina::Admin::Conferences::Blog::CategoriesController

Inherits:
AdminController
  • Object
show all
Defined in:
app/controllers/spina/admin/conferences/blog/categories_controller.rb

Overview

Spina::Admin::Conferences::Blog::CategoriesController

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @category = Spina::Admin::Conferences::Blog::Category.new category_params
  if @category.save
    redirect_to spina.edit_admin_conferences_blog_category_url(@category.id),
                notice: t('spina.blog.categories.saved')
  else
    add_breadcrumb I18n.t('spina.blog.categories.new')
    render :new, status: :unprocessable_entity
  end
end

#destroyObject



54
55
56
57
# File 'app/controllers/spina/admin/conferences/blog/categories_controller.rb', line 54

def destroy
  @category.destroy
  redirect_to spina.admin_conferences_blog_categories_path
end

#editObject



37
38
39
40
# File 'app/controllers/spina/admin/conferences/blog/categories_controller.rb', line 37

def edit
  add_breadcrumb @category.name
  render layout: 'spina/admin/admin'
end

#indexObject



16
17
18
# File 'app/controllers/spina/admin/conferences/blog/categories_controller.rb', line 16

def index
  @categories = Spina::Admin::Conferences::Blog::Category.order(:name)
end

#newObject



20
21
22
23
24
# File 'app/controllers/spina/admin/conferences/blog/categories_controller.rb', line 20

def new
  @category = Spina::Admin::Conferences::Blog::Category.new
  add_breadcrumb I18n.t('spina.blog.categories.new')
  render layout: 'spina/admin/admin'
end

#updateObject



42
43
44
45
46
47
48
49
50
51
52
# File 'app/controllers/spina/admin/conferences/blog/categories_controller.rb', line 42

def update
  add_breadcrumb @category.name
  if @category.update(category_params)
    add_breadcrumb @category.name
    redirect_to spina.edit_admin_conferences_blog_category_url(
      @category.id, params: { locale: @locale }
    ), notice: t('spina.blog.categories.saved')
  else
    render :edit, status: :unprocessable_entity
  end
end