Class: Spree::Api::TaxonomiesController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #set_jsonp_format
included
Instance Method Details
#create ⇒ Object
23
24
25
26
27
28
29
30
31
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 23
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
|
#destroy ⇒ Object
42
43
44
45
46
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 42
def destroy
authorize! :delete, Taxonomy
taxonomy.destroy
respond_with(taxonomy, :status => 204)
end
|
#index ⇒ Object
6
7
8
9
10
11
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 6
def index
@taxonomies = Taxonomy.order('name').includes(:root => :children).
ransack(params[:q]).result.
page(params[:page]).per(params[:per_page])
respond_with(@taxonomies)
end
|
#jstree ⇒ Object
Because JSTree wants parameters in a slightly different format
19
20
21
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 19
def jstree
show
end
|
#show ⇒ Object
13
14
15
16
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 13
def show
@taxonomy = Taxonomy.find(params[:id])
respond_with(@taxonomy)
end
|
#update ⇒ Object
33
34
35
36
37
38
39
40
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 33
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
|