Class: Navinshop::ItemsController

Inherits:
ApplicationController show all
Defined in:
app/controllers/navinshop/items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /items



27
28
29
30
31
32
33
34
35
# File 'app/controllers/navinshop/items_controller.rb', line 27

def create
  @item = Item.new(item_params)

  if @item.save
    redirect_to @item, notice: 'Item was successfully created.'
  else
    render :new
  end
end

#destroyObject

DELETE /items/1



47
48
49
50
# File 'app/controllers/navinshop/items_controller.rb', line 47

def destroy
  @item.destroy
  redirect_to items_url, notice: 'Item was successfully destroyed.'
end

#editObject

GET /items/1/edit



23
24
# File 'app/controllers/navinshop/items_controller.rb', line 23

def edit
end

#indexObject

GET /items



8
9
10
# File 'app/controllers/navinshop/items_controller.rb', line 8

def index
  @items = Item.all
end

#newObject

GET /items/new



17
18
19
20
# File 'app/controllers/navinshop/items_controller.rb', line 17

def new
  @item = Item.new
  @item.category_id=params[:category_id]
end

#showObject

GET /items/1



13
14
# File 'app/controllers/navinshop/items_controller.rb', line 13

def show
end

#updateObject

PATCH/PUT /items/1



38
39
40
41
42
43
44
# File 'app/controllers/navinshop/items_controller.rb', line 38

def update
  if @item.update(item_params)
    redirect_to @item, notice: 'Item was successfully updated.'
  else
    render :edit
  end
end