Fix Conflict
This commit is contained in:
76
app/controllers/settings/products_controller.rb
Normal file
76
app/controllers/settings/products_controller.rb
Normal file
@@ -0,0 +1,76 @@
|
||||
class Settings::ProductsController < ApplicationController
|
||||
before_action :set_settings_product, only: [:show, :edit, :update, :destroy]
|
||||
|
||||
# GET /settings/products
|
||||
# GET /settings/products.json
|
||||
def index
|
||||
@settings_products = Product.all
|
||||
end
|
||||
|
||||
# GET /settings/products/1
|
||||
# GET /settings/products/1.json
|
||||
def show
|
||||
end
|
||||
|
||||
# GET /settings/products/new
|
||||
def new
|
||||
@settings_product = Product.new
|
||||
end
|
||||
|
||||
# GET /settings/products/1/edit
|
||||
def edit
|
||||
end
|
||||
|
||||
# POST /settings/products
|
||||
# POST /settings/products.json
|
||||
def create
|
||||
|
||||
@settings_product = Product.new(settings_product_params)
|
||||
@settings_product.created_by = current_user.name
|
||||
respond_to do |format|
|
||||
if @settings_product.save
|
||||
format.html { redirect_to settings_products_path, notice: 'Product was successfully created.' }
|
||||
format.json { render :show, status: :created, location: @settings_product }
|
||||
else
|
||||
format.html { render :new }
|
||||
format.json { render json: @settings_product.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# PATCH/PUT /settings/products/1
|
||||
# PATCH/PUT /settings/products/1.json
|
||||
def update
|
||||
respond_to do |format|
|
||||
if @settings_product.update(settings_product_params)
|
||||
format.html { redirect_to settings_product_path, notice: 'Product was successfully updated.' }
|
||||
format.json { render :show, status: :ok, location: @settings_product }
|
||||
else
|
||||
format.html { render :edit }
|
||||
format.json { render json: @settings_product.errors, status: :unprocessable_entity }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
# DELETE /settings/products/1
|
||||
# DELETE /settings/products/1.json
|
||||
def destroy
|
||||
@settings_product.destroy
|
||||
respond_to do |format|
|
||||
format.html { redirect_to settings_products_path, notice: 'Product was successfully destroyed.' }
|
||||
format.json { head :no_content }
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
# Use callbacks to share common setup or constraints between actions.
|
||||
def set_settings_product
|
||||
@settings_product = Product.find(params[:id])
|
||||
end
|
||||
|
||||
# Never trust parameters from the scary internet, only allow the white list through.
|
||||
def settings_product_params
|
||||
params.require(:product).permit(:item_code, :name, :alt_name, :unit_price, :image_path, :description, :information, :taxable,:created_by)
|
||||
end
|
||||
|
||||
end
|
||||
Reference in New Issue
Block a user