Sha256: 7d89142ecb0410e10015548e70213a1c27b3798b6992817038dcefc2728227a9

Contents?: true

Size: 1.47 KB

Versions: 24

Compression:

Stored size: 1.47 KB

Contents

module Spree
  module Api
    class OptionTypesController < Spree::Api::BaseController
      def index
        if params[:ids]
          @option_types = Spree::OptionType.accessible_by(current_ability, :read).where(:id => params[:ids].split(','))
        else
          @option_types = Spree::OptionType.accessible_by(current_ability, :read).load.ransack(params[:q]).result
        end
        respond_with(@option_types)
      end

      def show
        @option_type = Spree::OptionType.accessible_by(current_ability, :read).find(params[:id])
        respond_with(@option_type)
      end

      def create
        authorize! :create, Spree::OptionType
        @option_type = Spree::OptionType.new(option_type_params)
        if @option_type.save
          render :show, :status => 201
        else
          invalid_resource!(@option_type)
        end
      end

      def update
        @option_type = Spree::OptionType.accessible_by(current_ability, :update).find(params[:id])
        if @option_type.update_attributes(option_type_params)
          render :show
        else
          invalid_resource!(@option_type)
        end
      end

      def destroy
        @option_type = Spree::OptionType.accessible_by(current_ability, :destroy).find(params[:id])
        @option_type.destroy
        render :text => nil, :status => 204
      end

      private
        def option_type_params
          params.require(:option_type).permit(permitted_option_type_attributes)
        end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
spree_api-2.4.0.rc2 app/controllers/spree/api/option_types_controller.rb
spree_api-2.4.0.rc1 app/controllers/spree/api/option_types_controller.rb
spree_api-2.3.4 app/controllers/spree/api/option_types_controller.rb
spree_api-2.1.9 app/controllers/spree/api/option_types_controller.rb
spree_api-2.2.6 app/controllers/spree/api/option_types_controller.rb
spree_api-2.3.3 app/controllers/spree/api/option_types_controller.rb
spree_api-2.3.2 app/controllers/spree/api/option_types_controller.rb
spree_api-2.2.5 app/controllers/spree/api/option_types_controller.rb
spree_api-2.1.8 app/controllers/spree/api/option_types_controller.rb
spree_api-2.3.1 app/controllers/spree/api/option_types_controller.rb
spree_api-2.2.4 app/controllers/spree/api/option_types_controller.rb
spree_api-2.2.3 app/controllers/spree/api/option_types_controller.rb
spree_api-2.3.0 app/controllers/spree/api/option_types_controller.rb
spree_api-2.2.2 app/controllers/spree/api/option_types_controller.rb
spree_api-2.1.7 app/controllers/spree/api/option_types_controller.rb
spree_api-2.1.6 app/controllers/spree/api/option_types_controller.rb
spree_api-2.2.1 app/controllers/spree/api/option_types_controller.rb
spree_api-2.2.0 app/controllers/spree/api/option_types_controller.rb
spree_api-2.1.5 app/controllers/spree/api/option_types_controller.rb
spree_api-2.1.4 app/controllers/spree/api/option_types_controller.rb