Class: Spree::Api::OptionValuesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::OptionValuesController
- Defined in:
- app/controllers/spree/api/option_values_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'app/controllers/spree/api/option_values_controller.rb', line 22 def create Spree::Deprecation.warn <<~MSG unless request.path.include?('/option_types/') This route is deprecated, as it'll be no longer possible to create an option_value without an associated option_type. Please, use instead: POST api/option_types/{option_type_id}/option_values MSG :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
50 51 52 53 54 55 56 |
# File 'app/controllers/spree/api/option_values_controller.rb', line 50 def destroy warn_if_nested_member_route @option_value = scope.accessible_by(current_ability, :destroy).find(params[:id]) @option_value.destroy render plain: nil, status: 204 end |
#index ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/controllers/spree/api/option_values_controller.rb', line 6 def index if params[:ids] @option_values = scope.where(id: params[:ids]) else @option_values = scope.ransack(params[:q]).result.distinct end respond_with(@option_values) end |
#show ⇒ Object
15 16 17 18 19 20 |
# File 'app/controllers/spree/api/option_values_controller.rb', line 15 def show warn_if_nested_member_route @option_value = scope.find(params[:id]) respond_with(@option_value) end |
#update ⇒ Object
39 40 41 42 43 44 45 46 47 48 |
# File 'app/controllers/spree/api/option_values_controller.rb', line 39 def update warn_if_nested_member_route @option_value = scope.accessible_by(current_ability, :update).find(params[:id]) if @option_value.update(option_value_params) render :show else invalid_resource!(@option_value) end end |