Class: Navinshop::ItemsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- ApplicationController
- Navinshop::ItemsController
- Defined in:
- app/controllers/navinshop/items_controller.rb
Instance Method Summary collapse
-
#create ⇒ Object
POST /items.
-
#destroy ⇒ Object
DELETE /items/1.
-
#edit ⇒ Object
GET /items/1/edit.
-
#index ⇒ Object
GET /items.
-
#new ⇒ Object
GET /items/new.
-
#show ⇒ Object
GET /items/1.
-
#update ⇒ Object
PATCH/PUT /items/1.
Instance Method Details
#create ⇒ Object
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 |
#destroy ⇒ Object
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 |
#edit ⇒ Object
GET /items/1/edit
23 24 |
# File 'app/controllers/navinshop/items_controller.rb', line 23 def edit end |
#index ⇒ Object
GET /items
8 9 10 |
# File 'app/controllers/navinshop/items_controller.rb', line 8 def index @items = Item.all end |
#new ⇒ Object
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 |
#show ⇒ Object
GET /items/1
13 14 |
# File 'app/controllers/navinshop/items_controller.rb', line 13 def show end |
#update ⇒ Object
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 |