Class: Spree::Api::V1::StockMovementsController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/v1/stock_movements_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#content_type, #permitted_line_item_attributes

Methods included from ControllerSetup

included

Instance Method Details

#createObject



18
19
20
21
22
23
24
25
26
# File 'app/controllers/spree/api/v1/stock_movements_controller.rb', line 18

def create
  authorize! :create, StockMovement
  @stock_movement = scope.new(stock_movement_params)
  if @stock_movement.save
    respond_with(@stock_movement, status: 201, default_template: :show)
  else
    invalid_resource!(@stock_movement)
  end
end

#indexObject



7
8
9
10
11
# File 'app/controllers/spree/api/v1/stock_movements_controller.rb', line 7

def index
  authorize! :read, StockMovement
  @stock_movements = scope.ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
  respond_with(@stock_movements)
end

#showObject



13
14
15
16
# File 'app/controllers/spree/api/v1/stock_movements_controller.rb', line 13

def show
  @stock_movement = scope.find(params[:id])
  respond_with(@stock_movement)
end