Sha256: 120c9e3bd94d5bb575a2a161c278c0a8470259090bf8509f56d5960256d2bc37
Contents?: true
Size: 1.19 KB
Versions: 2
Compression:
Stored size: 1.19 KB
Contents
module Kms module Catalog class VariantsController < ApplicationController def index @product = Product.find_by_id(params[:product_id]) @variants = @product.variants render json: @variants.to_json end def show @variant = Variant.find_by_id(params[:id]) render json: @variant.to_json end def create @variant = Variant.create(variant_params.merge({product_id: params[:product_id]})) render json: @variant.to_json end def update @variant = Variant.find(params[:id]) @variant.update_attributes(variant_params) render json: @variant.to_json end def destroy @variant = Variant.find_by_id(params[:id]) @variant.destroy render json: @variant.to_json end 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 protected def variant_params params.require(:variant).permit! end end end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
kms_catalog-0.5.0 | app/controllers/kms/catalog/variants_controller.rb |
kms_catalog-0.4.0 | app/controllers/kms/catalog/variants_controller.rb |