Class: Spree::Api::OptionTypesController
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#map_nested_attributes_keys, #set_jsonp_format
included
Instance Method Details
#create ⇒ Object
18
19
20
21
22
23
24
25
26
|
# File 'app/controllers/spree/api/option_types_controller.rb', line 18
def create
authorize! :create, Spree::OptionType
@option_type = Spree::OptionType.new(params[:option_type])
if @option_type.save
render :show, :status => 201
else
invalid_resource!(@option_type)
end
end
|
#destroy ⇒ Object
38
39
40
41
42
43
|
# File 'app/controllers/spree/api/option_types_controller.rb', line 38
def destroy
authorize! :destroy, Spree::OptionType
@option_type = Spree::OptionType.find(params[:id])
@option_type.destroy
render :text => nil, :status => 204
end
|
#index ⇒ Object
4
5
6
7
8
9
10
11
|
# File 'app/controllers/spree/api/option_types_controller.rb', line 4
def index
if params[:ids]
@option_types = Spree::OptionType.where(:id => params[:ids].split(','))
else
@option_types = Spree::OptionType.scoped.ransack(params[:q]).result
end
respond_with(@option_types)
end
|
#show ⇒ Object
13
14
15
16
|
# File 'app/controllers/spree/api/option_types_controller.rb', line 13
def show
@option_type = Spree::OptionType.find(params[:id])
respond_with(@option_type)
end
|
#update ⇒ Object
28
29
30
31
32
33
34
35
36
|
# File 'app/controllers/spree/api/option_types_controller.rb', line 28
def update
authorize! :update, Spree::OptionType
@option_type = Spree::OptionType.find(params[:id])
if @option_type.update_attributes(params[:option_type])
render :show
else
invalid_resource!(@option_type)
end
end
|