Class: Spree::Admin::StockItemsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/admin/stock_items_controller.rb

Instance Method Summary collapse

Instance Method Details

#createObject



13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'app/controllers/spree/admin/stock_items_controller.rb', line 13

def create
  variant = Variant.find(params[:variant_id])
  stock_location = StockLocation.find(params[:stock_location_id])
  stock_movement = stock_location.stock_movements.build(stock_movement_params)
  stock_movement.stock_item = stock_location.set_up_stock_item(variant)

  if stock_movement.save
    flash[:success] = flash_message_for(stock_movement, :successfully_created)
  else
    flash[:error] = Spree.t(:could_not_create_stock_movement)
  end

  redirect_to :back
end

#destroyObject



28
29
30
31
32
33
34
35
# File 'app/controllers/spree/admin/stock_items_controller.rb', line 28

def destroy
  stock_item.destroy

  respond_with(@stock_item) do |format|
    format.html { redirect_to :back }
    format.js
  end
end

#updateObject



6
7
8
9
10
11
# File 'app/controllers/spree/admin/stock_items_controller.rb', line 6

def update
  stock_item.save
  respond_to do |format|
    format.js { head :ok }
  end
end