2024-01-17 01:44:36 -06:00
|
|
|
class VendorsController < ApplicationController
|
|
|
|
def index
|
2024-01-30 00:04:20 -06:00
|
|
|
@vendors = Vendor.order(:name).page(params[:page]).per(5) # Adjust the number per page as needed
|
2024-01-17 01:44:36 -06:00
|
|
|
end
|
|
|
|
|
|
|
|
def show
|
|
|
|
@vendor = Vendor.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def new
|
|
|
|
@vendor = Vendor.new
|
|
|
|
end
|
|
|
|
|
|
|
|
def create
|
|
|
|
@vendor = Vendor.new(vendor_params)
|
|
|
|
if @vendor.save
|
|
|
|
redirect_to @vendor
|
|
|
|
else
|
|
|
|
render :new
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def edit
|
|
|
|
@vendor = Vendor.find(params[:id])
|
|
|
|
end
|
|
|
|
|
|
|
|
def update
|
|
|
|
@vendor = Vendor.find(params[:id])
|
|
|
|
if @vendor.update(vendor_params)
|
|
|
|
redirect_to @vendor
|
|
|
|
else
|
|
|
|
render :edit
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
def destroy
|
|
|
|
@vendor = Vendor.find(params[:id])
|
|
|
|
@vendor.destroy
|
|
|
|
redirect_to vendors_path
|
|
|
|
end
|
|
|
|
|
|
|
|
private
|
|
|
|
def vendor_params
|
|
|
|
params.require(:vendor).permit(:name, :address, :phone, :email, :dba, :tin, :contact)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|