Class: Admin::CategoriesController

Inherits:
AdminController show all
Defined in:
app/controllers/admin/categories_controller.rb

Instance Attribute Summary

Attributes included from PagesCore::Authentication

#current_user

Instance Method Summary collapse

Methods inherited from PagesCore::AdminController

#redirect, underscore

Methods included from PagesCore::StaticCacheController

#disable_static_cache!

Methods included from PagesCore::PoliciesHelper

#policy, #verify_policy, #verify_policy_with_proc

Methods included from PagesCore::ProcessTitler

inc_number_of_requests, original_title

Methods included from PagesCore::ErrorRenderer

#render_error

Methods included from PagesCore::Authentication

#authenticate!, #deauthenticate!, #logged_in?

Instance Method Details

#createObject



19
20
21
22
23
24
25
26
27
# File 'app/controllers/admin/categories_controller.rb', line 19

def create
  @category = Category.create(category_params)
  if @category.valid?
    flash[:notice] = t("pages_core.categories_controller.created")
    redirect_to admin_pages_url(@locale)
  else
    render action: :new
  end
end

#destroyObject



40
41
42
43
44
# File 'app/controllers/admin/categories_controller.rb', line 40

def destroy
  @category.destroy
  flash[:notice] = t("pages_core.categories_controller.deleted")
  redirect_to admin_pages_url(@locale)
end

#editObject



29
# File 'app/controllers/admin/categories_controller.rb', line 29

def edit; end

#indexObject



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

def index
  @categories = Category.all
end

#newObject



15
16
17
# File 'app/controllers/admin/categories_controller.rb', line 15

def new
  @category = Category.new
end

#showObject



11
12
13
# File 'app/controllers/admin/categories_controller.rb', line 11

def show
  redirect_to edit_admin_category_url(@category)
end

#updateObject



31
32
33
34
35
36
37
38
# File 'app/controllers/admin/categories_controller.rb', line 31

def update
  if @category.update(category_params)
    flash[:notice] = t("pages_core.categories_controller.updated")
    redirect_to admin_pages_url(@locale)
  else
    render action: :edit
  end
end