Sha256: b26aaccd6f1a9c1613bd4e6bbc316b034c49129c80582735a33f272922dfd3a1

Contents?: true

Size: 1.44 KB

Versions: 82

Compression:

Stored size: 1.44 KB

Contents

module Spree
  module Api
    class StockLocationsController < Spree::Api::BaseController
      def index
        authorize! :read, StockLocation
        @stock_locations = StockLocation.accessible_by(current_ability, :read).order('name ASC').ransack(params[:q]).result.page(params[:page]).per(params[:per_page])
        respond_with(@stock_locations)
      end

      def show
        respond_with(stock_location)
      end

      def create
        authorize! :create, StockLocation
        @stock_location = StockLocation.new(stock_location_params)
        if @stock_location.save
          respond_with(@stock_location, status: 201, default_template: :show)
        else
          invalid_resource!(@stock_location)
        end
      end

      def update
        authorize! :update, stock_location
        if stock_location.update_attributes(stock_location_params)
          respond_with(stock_location, status: 200, default_template: :show)
        else
          invalid_resource!(stock_location)
        end
      end

      def destroy
        authorize! :destroy, stock_location
        stock_location.destroy
        respond_with(stock_location, :status => 204)
      end

      private

      def stock_location
        @stock_location ||= StockLocation.accessible_by(current_ability, :read).find(params[:id])
      end

      def stock_location_params
        params.require(:stock_location).permit(permitted_stock_location_attributes)
      end
    end
  end
end

Version data entries

82 entries across 82 versions & 2 rubygems

Version Path
solidus_api-1.2.3 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.1.4 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.0.7 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.0.6 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.2.2 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.2.1 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.1.3 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.0.5 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.2.0 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.2.0.rc2 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.0.4 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.1.2 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.2.0.rc1 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.2.0.beta1 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.0.3 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.1.1 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.1.0 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.1.0.pre2 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.1.0.pre1 app/controllers/spree/api/stock_locations_controller.rb
solidus_api-1.1.0.beta1 app/controllers/spree/api/stock_locations_controller.rb