Sha256: 7f506a4f2e2105883714873a380b2eb744fbb9f531c3bd327b6effe6d3d22e26

Contents?: true

Size: 1.54 KB

Versions: 64

Compression:

Stored size: 1.54 KB

Contents

module Spree
  module Api
    module V1
      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
end

Version data entries

64 entries across 64 versions & 2 rubygems

Version Path
goca-spree-api-3.1.14.rails.5.0.1 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.14.1 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.14 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.13 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.12 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.11 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.4.6 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.10 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.9 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.8 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.7 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.6 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.5 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.4 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.3 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.2 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.1 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.0 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.7.0.rc3 app/controllers/spree/api/v1/stock_locations_controller.rb
spree_api-3.2.9 app/controllers/spree/api/v1/stock_locations_controller.rb