Class: Kms::Catalog::VariantsController
- Inherits:
-
ApplicationController
- Object
- ApplicationController
- Kms::Catalog::VariantsController
- Defined in:
- app/controllers/kms/catalog/variants_controller.rb
Instance Method Summary collapse
- #available_option_types ⇒ Object
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
- #show ⇒ Object
- #update ⇒ Object
Instance Method Details
#available_option_types ⇒ Object
32 33 34 35 36 37 |
# File 'app/controllers/kms/catalog/variants_controller.rb', line 32 def available_option_types @product = Product.find_by_id(params[:product_id]) @variant = Variant.find_by_id(params[:id]) @option_types = @product.option_types - @variant.option_values.map(&:option_type) render json: @option_types.to_json end |
#create ⇒ Object
15 16 17 18 |
# File 'app/controllers/kms/catalog/variants_controller.rb', line 15 def create @variant = Variant.create(variant_params.merge({product_id: params[:product_id]})) render json: @variant.to_json end |
#destroy ⇒ Object
26 27 28 29 30 |
# File 'app/controllers/kms/catalog/variants_controller.rb', line 26 def destroy @variant = Variant.find_by_id(params[:id]) @variant.destroy render json: @variant.to_json end |
#index ⇒ Object
4 5 6 7 8 |
# File 'app/controllers/kms/catalog/variants_controller.rb', line 4 def index @product = Product.find_by_id(params[:product_id]) @variants = @product.variants render json: @variants.to_json end |
#show ⇒ Object
10 11 12 13 |
# File 'app/controllers/kms/catalog/variants_controller.rb', line 10 def show @variant = Variant.find_by_id(params[:id]) render json: @variant.to_json end |
#update ⇒ Object
20 21 22 23 24 |
# File 'app/controllers/kms/catalog/variants_controller.rb', line 20 def update @variant = Variant.find(params[:id]) @variant.update_attributes(variant_params) render json: @variant.to_json end |