Class: Admin::PostCategoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/admin/post_categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



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

def create
  @post_category = SpudPostCategory.new(category_params)
  if @post_category.save
    flash.now[:notice] = 'Post Category was successfully created'
    respond_with @post_category, location: admin_post_categories_path
  else
    render 'new', status: :unprocessable_entity
  end
end

#destroyObject



41
42
43
44
45
46
47
48
49
# File 'app/controllers/admin/post_categories_controller.rb', line 41

def destroy
  if @post_category.destroy
    flash.now[:notice] = 'Post Category was successfully deleted'
    @post_categories = SpudPostCategory.ordered
    render 'index'
  else
    respond_with @post_category, location: admin_post_categories_path
  end
end

#editObject



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

def edit
  respond_with @post_category
end

#indexObject



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

def index
  @post_categories = SpudPostCategory.ordered
  respond_with @post_categories
end

#newObject



26
27
28
29
# File 'app/controllers/admin/post_categories_controller.rb', line 26

def new
  @post_category = SpudPostCategory.new
  respond_with @post_category
end

#updateObject



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

def update
  if @post_category.update(category_params)
    flash.now[:notice] = 'Post Category was successfully updated'
    respond_with @post_category, location: admin_post_categories_path
  else
    render 'new', status: :unprocessable_entity
  end
end