Class: Admin::CategoriesController

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

Instance Method Summary collapse

Instance Method Details

#createObject



37
38
39
40
41
42
43
44
45
46
47
48
49
# File 'app/controllers/wafflemix/admin/categories_controller.rb', line 37

def create
  @category = Category.new(params[:category])
  
  respond_to do |format|
    if @category.save
      format.html { redirect_to admin_categories_path, notice: 'Category was successfully created.' }
      format.json { render json: @category, status: :created, location: @category }
    else
      format.html { render action: "new" }
      format.json { render json: @category.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject



65
66
67
68
69
70
71
72
73
# File 'app/controllers/wafflemix/admin/categories_controller.rb', line 65

def destroy
  @category = Category.find(params[:id])
  @category.destroy
  
  respond_to do |format|
    format.html { redirect_to admin_categories_path }
    format.json { head :no_content }
  end
end

#editObject



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

def edit
  @category = Category.find(params[:id])
end

#indexObject



6
7
8
9
10
11
12
13
# File 'app/controllers/wafflemix/admin/categories_controller.rb', line 6

def index
  @categories = Category.all
  
  respond_to do |format|
    format.html
    format.json { render json: @categories }
  end
end

#newObject



24
25
26
27
28
29
30
31
# File 'app/controllers/wafflemix/admin/categories_controller.rb', line 24

def new
  @category = Category.new
  
  respond_to do |format|
    format.html
    format.json { render json: @category }
  end
end

#showObject



15
16
17
18
19
20
21
22
# File 'app/controllers/wafflemix/admin/categories_controller.rb', line 15

def show
  @category = Category.find(params[:id])
  
  respond_to do |format|
    format.html
    format.json { render json: @category }
  end
end

#updateObject



51
52
53
54
55
56
57
58
59
60
61
62
63
# File 'app/controllers/wafflemix/admin/categories_controller.rb', line 51

def update
  @category = Category.find(params[:id])
  
  respond_to do |format|
    if @category.update_attributes(params[:category])
      format.html { redirect_to admin_categories_path, notice: 'Category was successfully updated.' }
      format.json { head :no_content }
    else
      format.html { render action: "edit" }
      format.json { render json: @category.errors, status: :unprocessable_entity }
    end
  end
end