Sha256: 92016db34d213b9f1fe051f79495fad175921a70f41998753f2ba449b528c4e3

Contents?: true

Size: 1.23 KB

Versions: 15

Compression:

Stored size: 1.23 KB

Contents

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

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

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

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

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

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
spree_api-2.0.13 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.12 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.11 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.10 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.9 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.8 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.7 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.6 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.5 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.4 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.3 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.2 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.1 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.0 app/controllers/spree/api/option_types_controller.rb
spree_api-2.0.0.rc1 app/controllers/spree/api/option_types_controller.rb