Class: Gamification::InventoriesController

Inherits:
ApplicationController
  • Object
show all
Defined in:
app/controllers/gamification/inventories_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject

POST /gamification/inventories



26
27
28
29
30
31
32
33
34
35
36
# File 'app/controllers/gamification/inventories_controller.rb', line 26

def create
  authorize! :create, @gamification_inventory

  @gamification_inventory = Gamification::Inventory.new(inventory_params)

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

#destroyObject

DELETE /gamification/inventories/1



53
54
55
56
# File 'app/controllers/gamification/inventories_controller.rb', line 53

def destroy
  @gamification_inventory.destroy
  redirect_to gamification_inventories_url, notice: 'Inventory was successfully destroyed.'
end

#editObject

GET /gamification/inventories/1/edit



22
23
# File 'app/controllers/gamification/inventories_controller.rb', line 22

def edit
end

#indexObject

GET /gamification/inventories



8
9
10
# File 'app/controllers/gamification/inventories_controller.rb', line 8

def index
  @gamification_inventories = Gamification::Inventory.all
end

#newObject

GET /gamification/inventories/new



17
18
19
# File 'app/controllers/gamification/inventories_controller.rb', line 17

def new
  @gamification_inventory = Gamification::Inventory.new
end

#showObject

GET /gamification/inventories/1



13
14
# File 'app/controllers/gamification/inventories_controller.rb', line 13

def show
end

#updateObject

PATCH/PUT /gamification/inventories/1



39
40
41
42
43
44
45
46
47
48
49
50
# File 'app/controllers/gamification/inventories_controller.rb', line 39

def update
  respond_to do |format|
    if @gamification_inventory.equip_item(params[:user_id].to_i)

      format.js
      format.json { head :no_content }
    else
      format.js
      format.json { render json: @gamification_inventory.errors, status: :unprocessable_entity }
    end
  end
end