Sha256: 27b7fb2e615b9cb30e00ad51859bbdf8b3397a1888ac43c4698397bfa1f16b82
Contents?: true
Size: 1.05 KB
Versions: 4
Compression:
Stored size: 1.05 KB
Contents
module Spree module Api class StockMovementsController < Spree::Api::BaseController before_filter :stock_location, except: [:update, :destroy] def index @stock_movements = scope.ransack(params[:q]).result.page(params[:page]).per(params[:per_page]) respond_with(@stock_movements) end def show @stock_movement = scope.find(params[:id]) respond_with(@stock_movement) end def create authorize! :create, StockMovement @stock_movement = scope.new(params[:stock_movement]) if @stock_movement.save respond_with(@stock_movement, status: 201, default_template: :show) else invalid_resource!(@stock_movement) end end private def stock_location render 'spree/api/shared/stock_location_required', status: 422 and return unless params[:stock_location_id] @stock_location ||= StockLocation.find(params[:stock_location_id]) end def scope @stock_location.stock_movements end end end end
Version data entries
4 entries across 4 versions & 1 rubygems