Sha256: 358ece29a123397e4b470e6e09b03b23f2a3618044ce1951b0e133927f43128b
Contents?: true
Size: 1.34 KB
Versions: 15
Compression:
Stored size: 1.34 KB
Contents
module Spree module Api class TaxonomiesController < Spree::Api::BaseController respond_to :json def index @taxonomies = Taxonomy.order('name').includes(:root => :children). ransack(params[:q]).result. page(params[:page]).per(params[:per_page]) respond_with(@taxonomies) end def show @taxonomy = Taxonomy.find(params[:id]) respond_with(@taxonomy) end # Because JSTree wants parameters in a *slightly* different format def jstree show end def create authorize! :create, Taxonomy @taxonomy = Taxonomy.new(params[:taxonomy]) if @taxonomy.save respond_with(@taxonomy, :status => 201, :default_template => :show) else invalid_resource!(@taxonomy) end end def update authorize! :update, Taxonomy if taxonomy.update_attributes(params[:taxonomy]) respond_with(taxonomy, :status => 200, :default_template => :show) else invalid_resource!(taxonomy) end end def destroy authorize! :delete, Taxonomy taxonomy.destroy respond_with(taxonomy, :status => 204) end private def taxonomy @taxonomy ||= Taxonomy.find(params[:id]) end end end end
Version data entries
15 entries across 15 versions & 1 rubygems