Sha256: af57a16516cb1fc86db9c7b297320e127c0307fb284a95178e8549b07dc9aa09

Contents?: true

Size: 1.05 KB

Versions: 10

Compression:

Stored size: 1.05 KB

Contents

module Spree
  module Api
    module V1
      class TaxonomiesController < Spree::Api::V1::BaseController
        def index
          @taxonomies = Taxonomy.order('name').includes(:root => :children)
        end

        def show
          @taxonomy = Taxonomy.find(params[:id])
        end

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

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

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

        private

        def taxonomy
          @taxonomy ||= Taxonomy.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/taxonomies_controller.rb
spree_api-1.1.5 app/controllers/spree/api/v1/taxonomies_controller.rb
spree_api-1.1.4 app/controllers/spree/api/v1/taxonomies_controller.rb
spree_api-1.2.0 app/controllers/spree/api/v1/taxonomies_controller.rb
spree_api-1.2.0.rc2 app/controllers/spree/api/v1/taxonomies_controller.rb
spree_api-1.2.0.rc1 app/controllers/spree/api/v1/taxonomies_controller.rb
spree_api-1.1.3 app/controllers/spree/api/v1/taxonomies_controller.rb
spree_api-1.1.2 app/controllers/spree/api/v1/taxonomies_controller.rb
spree_api-1.1.2.rc1 app/controllers/spree/api/v1/taxonomies_controller.rb
spree_api-1.1.1 app/controllers/spree/api/v1/taxonomies_controller.rb