Class: Spree::Api::TaxonomiesController

Inherits:
BaseController
  • Object
show all
Defined in:
app/controllers/spree/api/taxonomies_controller.rb

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Instance Method Details

#createObject



24
25
26
27
28
29
30
31
32
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 24

def create
  authorize! :create, Taxonomy
  @taxonomy = Spree::Taxonomy.new(taxonomy_params)
  if @taxonomy.save
    respond_with(@taxonomy, status: 201, default_template: :show)
  else
    invalid_resource!(@taxonomy)
  end
end

#destroyObject



43
44
45
46
47
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 43

def destroy
  authorize! :destroy, taxonomy
  taxonomy.destroy
  respond_with(taxonomy, status: 204)
end

#indexObject



6
7
8
9
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 6

def index
  @taxonomies = paginate(taxonomies)
  respond_with(@taxonomies)
end

#jstreeObject

Because JSTree wants parameters in a slightly different format



19
20
21
22
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 19

def jstree
  Spree::Deprecation.warn("Please don't use `/api/taxonomies/:taxonomy_id/jstree` endpoint. It is deprecated and will be removed in the next future.", caller)
  show
end

#newObject



11
12
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 11

def new
end

#showObject



14
15
16
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 14

def show
  respond_with(taxonomy)
end

#updateObject



34
35
36
37
38
39
40
41
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 34

def update
  authorize! :update, taxonomy
  if taxonomy.update_attributes(taxonomy_params)
    respond_with(taxonomy, status: 200, default_template: :show)
  else
    invalid_resource!(taxonomy)
  end
end