Sha256: 1cd36aefa76806ae41cffdb078f1a808948df54bd4252c729b9f4ab6afbb4594

Contents?: true

Size: 932 Bytes

Versions: 2

Compression:

Stored size: 932 Bytes

Contents

module Kms
  module Catalog
    class OptionValuesController < ApplicationController
      def index
        @product = Product.find_by_id(params[:product_id])
        @variant = @product.variants.find_by_id(params[:variant_id])
        @option_values = @variant.option_values
        render json: @option_values.to_json(methods: [:tag, :name])
      end

      def create
        @product = Product.find_by_id(params[:product_id])
        @variant = @product.variants.find_by_id(params[:variant_id])
        @option_value = @variant.option_values.create(option_values_params)
        render json: @option_value.to_json
      end

      def destroy
        @option_value = OptionValue.find_by_id(params[:id])
        @option_value.destroy if @option_value
        render json: @option_value.to_json
      end

      protected

      def option_values_params
        params.require(:option_value).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/option_values_controller.rb
kms_catalog-0.4.0 app/controllers/kms/catalog/option_values_controller.rb