Class: Spree::Api::V1::TaxonomiesController
- Inherits:
-
BaseController
- Object
- ActionController::Metal
- BaseController
- Spree::Api::V1::TaxonomiesController
show all
- Defined in:
- app/controllers/spree/api/v1/taxonomies_controller.rb
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys
included
Instance Method Details
#create ⇒ Object
16
17
18
19
20
21
22
23
24
|
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 16
def create
authorize! :create, Taxonomy
@taxonomy = Taxonomy.new(params[:taxonomy])
if @taxonomy.save
render :show, :status => 201
else
invalid_resource!(@taxonomy)
end
end
|
#destroy ⇒ Object
35
36
37
38
39
|
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 35
def destroy
authorize! :delete, Taxonomy
taxonomy.destroy
render :text => nil, :status => 204
end
|
#index ⇒ Object
5
6
7
8
9
10
|
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 5
def index
@taxonomies = Taxonomy.
order('name').includes(:root => :children).
ransack(params[:q]).result.
page(params[:page]).per(params[:per_page])
end
|
#show ⇒ Object
12
13
14
|
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 12
def show
@taxonomy = Taxonomy.find(params[:id])
end
|
#update ⇒ Object
26
27
28
29
30
31
32
33
|
# File 'app/controllers/spree/api/v1/taxonomies_controller.rb', line 26
def update
authorize! :update, Taxonomy
if taxonomy.update_attributes(params[:taxonomy])
render :show, :status => 200
else
invalid_resource!(taxonomy)
end
end
|