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::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


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

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

#destroyObject


38
39
40
41
42
# File 'app/controllers/admin/categories_controller.rb', line 38

def destroy
  @category.destroy
  flash[:notice] = "Category was deleted"
  redirect_to admin_pages_url(@locale)
end

#editObject


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

def edit; end

#indexObject


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

def index
  @categories = Category.all
end

#newObject


13
14
15
# File 'app/controllers/admin/categories_controller.rb', line 13

def new
  @category = Category.new
end

#showObject


9
10
11
# File 'app/controllers/admin/categories_controller.rb', line 9

def show
  redirect_to edit_admin_category_url(@category)
end

#updateObject


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

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