Class: Spree::Api::V1::OptionValuesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::V1::OptionValuesController
show all
- Defined in:
- app/controllers/spree/api/v1/option_values_controller.rb
Instance Attribute Summary
#current_api_user
Instance Method Summary
collapse
#content_type, #permitted_line_item_attributes
included
Instance Method Details
#create ⇒ Object
21
22
23
24
25
26
27
28
29
|
# File 'app/controllers/spree/api/v1/option_values_controller.rb', line 21
def create
authorize! :create, Spree::OptionValue
@option_value = scope.new(option_value_params)
if @option_value.save
render :show, status: 201
else
invalid_resource!(@option_value)
end
end
|
#destroy ⇒ Object
40
41
42
43
44
|
# File 'app/controllers/spree/api/v1/option_values_controller.rb', line 40
def destroy
@option_value = scope.accessible_by(current_ability, :destroy).find(params[:id])
@option_value.destroy
render plain: nil, status: 204
end
|
#index ⇒ Object
5
6
7
8
9
10
11
12
|
# File 'app/controllers/spree/api/v1/option_values_controller.rb', line 5
def index
@option_values = if params[:ids]
scope.where(id: params[:ids])
else
scope.ransack(params[:q]).result.distinct
end
respond_with(@option_values)
end
|
#new ⇒ Object
19
|
# File 'app/controllers/spree/api/v1/option_values_controller.rb', line 19
def new; end
|
#show ⇒ Object
14
15
16
17
|
# File 'app/controllers/spree/api/v1/option_values_controller.rb', line 14
def show
@option_value = scope.find(params[:id])
respond_with(@option_value)
end
|
#update ⇒ Object
31
32
33
34
35
36
37
38
|
# File 'app/controllers/spree/api/v1/option_values_controller.rb', line 31
def update
@option_value = scope.accessible_by(current_ability, :update).find(params[:id])
if @option_value.update_attributes(option_value_params)
render :show
else
invalid_resource!(@option_value)
end
end
|