Sha256: 64a6e5a35c127cee5f0d6100ea1b03c94c580f17515f29e129291edb5d6611e4
Contents?: true
Size: 1.48 KB
Versions: 15
Compression:
Stored size: 1.48 KB
Contents
module Spree module Api class StockLocationsController < Spree::Api::BaseController def index authorize! :read, Spree::StockLocation @stock_locations = Spree::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, Spree::StockLocation @stock_location = Spree::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 ||= Spree::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
15 entries across 15 versions & 1 rubygems