Continue adding product variants
This commit is contained in:
@@ -24,6 +24,13 @@ module Suppliers
|
||||
# POST /product_variants
|
||||
# POST /product_variants.json
|
||||
def create
|
||||
@product_variant = ProductVariant.new(product_variant_params)
|
||||
@product_variant.supplier = current_supplier
|
||||
if @product_variant.save
|
||||
render json: @product_variant
|
||||
else
|
||||
render json: {errors: @product_variant.errors}, status: :unprocessable_entity
|
||||
end
|
||||
end
|
||||
|
||||
# PUT /product_variants/1
|
||||
@@ -44,13 +51,10 @@ module Suppliers
|
||||
# DELETE /product_variants/1
|
||||
# DELETE /product_variants/1.json
|
||||
def destroy
|
||||
@product_variant = ProductVariant.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
#@product_variant = ProductVariant.find_by_supplier_id_and_id!(current_supplier.id, params[:id])
|
||||
@product_variant = ProductVariant.find(params[:id])
|
||||
@product_variant.destroy
|
||||
|
||||
respond_to do |format|
|
||||
format.html { redirect_to suppliers_product_variants_url, notice: t('action.destroy.successfull', model: ProductVariant.model_name.human) }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
render json: {}
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
Reference in New Issue
Block a user