Class: Spree::Api::OptionTypesController
- Inherits:
-
BaseController
- Object
- ActionController::Base
- BaseController
- Spree::Api::OptionTypesController
- Defined in:
- app/controllers/spree/api/option_types_controller.rb
Instance Attribute Summary
Attributes inherited from BaseController
Instance Method Summary collapse
Instance Method Details
#create ⇒ Object
20 21 22 23 24 25 26 27 28 |
# File 'app/controllers/spree/api/option_types_controller.rb', line 20 def create :create, Spree::OptionType @option_type = Spree::OptionType.new(option_type_params) if @option_type.save render :show, status: 201 else invalid_resource!(@option_type) end end |
#destroy ⇒ Object
39 40 41 42 43 |
# File 'app/controllers/spree/api/option_types_controller.rb', line 39 def destroy @option_type = Spree::OptionType.accessible_by(current_ability, :destroy).find(params[:id]) @option_type.destroy render plain: nil, status: 204 end |
#index ⇒ Object
6 7 8 9 10 11 12 13 |
# File 'app/controllers/spree/api/option_types_controller.rb', line 6 def index if params[:ids] @option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability).where(id: params[:ids].split(',')) else @option_types = Spree::OptionType.includes(:option_values).accessible_by(current_ability).load.ransack(params[:q]).result end respond_with(@option_types) end |
#show ⇒ Object
15 16 17 18 |
# File 'app/controllers/spree/api/option_types_controller.rb', line 15 def show @option_type = Spree::OptionType.accessible_by(current_ability, :show).find(params[:id]) respond_with(@option_type) end |
#update ⇒ Object
30 31 32 33 34 35 36 37 |
# File 'app/controllers/spree/api/option_types_controller.rb', line 30 def update @option_type = Spree::OptionType.accessible_by(current_ability, :update).find(params[:id]) if @option_type.update(option_type_params) render :show else invalid_resource!(@option_type) end end |