Sha256: 568d5c520eef76a1fc241b0d55403eab71a6f48407f05555a3074e1c4366ad7c
Contents?: true
Size: 1.1 KB
Versions: 5
Compression:
Stored size: 1.1 KB
Contents
module Spree module Api class TaxonsController < Spree::Api::BaseController respond_to :json def index @taxons = taxonomy.root.children respond_with(@taxons) end def show @taxon = taxon respond_with(@taxon) end def create authorize! :create, Taxon @taxon = Taxon.new(params[:taxon]) if @taxon.save respond_with(@taxon, :status => 201, :default_template => :show) else invalid_resource!(@taxon) end end def update authorize! :update, Taxon if taxon.update_attributes(params[:taxon]) respond_with(taxon, :status => 200, :default_template => :show) else invalid_resource!(taxon) end end def destroy authorize! :delete, Taxon taxon.destroy respond_with(taxon, :status => 204) end private def taxonomy @taxonomy ||= Taxonomy.find(params[:taxonomy_id]) end def taxon @taxon ||= taxonomy.taxons.find(params[:id]) end end end end
Version data entries
5 entries across 5 versions & 2 rubygems