Class: GraphStarter::CategoriesController

Inherits:
ApplicationController show all
Defined in:
app/controllers/graph_starter/categories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /categories POST /categories.json



27
28
29
30
31
32
33
34
35
36
37
38
39
# File 'app/controllers/graph_starter/categories_controller.rb', line 27

def create
  @category = Category.new(category_params)

  respond_to do |format|
    if @category.save
      format.html { redirect_to @category, notice: 'Category was successfully created.' }
      format.json { render :show, status: :created, location: @category }
    else
      format.html { render :new }
      format.json { render json: @category.errors, status: :unprocessable_entity }
    end
  end
end

#destroyObject

DELETE /categories/1 DELETE /categories/1.json



57
58
59
60
61
62
63
64
65
# File 'app/controllers/graph_starter/categories_controller.rb', line 57

def destroy
  @category.destroy
  respond_to do |format|
    format.html do
      redirect_to categories_url, notice: 'Category was successfully destroyed.'
    end
    format.json { head :no_content }
  end
end

#editObject

GET /categories/1/edit



22
23
# File 'app/controllers/graph_starter/categories_controller.rb', line 22

def edit
end

#indexObject

GET /categories GET /categories.json



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

def index
  @categories = Category.all
end

#newObject

GET /categories/new



17
18
19
# File 'app/controllers/graph_starter/categories_controller.rb', line 17

def new
  @category = Category.new
end

#showObject

GET /categories/1 GET /categories/1.json



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

def show
end

#updateObject

PATCH/PUT /categories/1 PATCH/PUT /categories/1.json



43
44
45
46
47
48
49
50
51
52
53
# File 'app/controllers/graph_starter/categories_controller.rb', line 43

def update
  respond_to do |format|
    if @category.update(category_params)
      format.html { redirect_to @category, notice: 'Category was successfully updated.' }
      format.json { render :show, status: :ok, location: @category }
    else
      format.html { render :edit }
      format.json { render json: @category.errors, status: :unprocessable_entity }
    end
  end
end