Class: Spree::Api::TaxonomiesController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #permitted_line_item_attributes, #set_jsonp_format
included
Instance Method Details
#create ⇒ Object
22
23
24
25
26
27
28
29
30
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 22
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
|
#destroy ⇒ Object
41
42
43
44
45
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 41
def destroy
authorize! :destroy, taxonomy
taxonomy.destroy
respond_with(taxonomy, :status => 204)
end
|
#index ⇒ Object
5
6
7
8
9
10
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 5
def index
@taxonomies = Taxonomy.accessible_by(current_ability, :read).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
18
19
20
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 18
def jstree
show
end
|
#show ⇒ Object
12
13
14
15
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 12
def show
@taxonomy = Taxonomy.accessible_by(current_ability, :read).find(params[:id])
respond_with(@taxonomy)
end
|
#update ⇒ Object
32
33
34
35
36
37
38
39
|
# File 'app/controllers/spree/api/taxonomies_controller.rb', line 32
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
|