Sha256: beb3a0083b63201fa64f21bccb3c95cb872bbceb83cd66a0d0c8def4c59b35ff

Contents?: true

Size: 1.04 KB

Versions: 10

Compression:

Stored size: 1.04 KB

Contents

module Spree
  module Api
    module V1
      class TaxonsController < Spree::Api::V1::BaseController
        def index
          @taxons = taxonomy.root.children
        end

        def show
          @taxon = taxon
        end

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

        def update
          authorize! :update, Taxon
          if taxon.update_attributes(params[:taxon])
            render :show, :status => 200
          else
            invalid_resource!(taxon)
          end
        end

        def destroy
          authorize! :delete, Taxon
          taxon.destroy
          render :text => nil, :status => 200
        end

        private

        def taxonomy
          @taxonomy ||= Taxonomy.find(params[:taxonomy_id])
        end

        def taxon
          @taxon ||= taxonomy.taxons.find(params[:id])
        end

      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
spree_api-1.1.6 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.1.5 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.1.4 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.2.0 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.2.0.rc2 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.2.0.rc1 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.1.3 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.1.2 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.1.2.rc1 app/controllers/spree/api/v1/taxons_controller.rb
spree_api-1.1.1 app/controllers/spree/api/v1/taxons_controller.rb