Class: Spree::Api::V1::TaxonomiesController

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

Instance Attribute Summary

Attributes inherited from BaseController

#current_api_user

Instance Method Summary collapse

Methods inherited from BaseController

#content_type, #permitted_line_item_attributes

Methods included from ControllerSetup

included

Instance Method Details

#createObject



20
21
22
23
24
25
26
27
28
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 20

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

#destroyObject



39
40
41
42
43
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 39

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

#indexObject



5
6
7
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 5

def index
  respond_with(taxonomies)
end

#jstreeObject

Because JSTree wants parameters in a slightly different format



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

def jstree
  show
end

#newObject



18
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 18

def new; end

#showObject



9
10
11
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 9

def show
  respond_with(taxonomy)
end

#updateObject



30
31
32
33
34
35
36
37
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 30

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