75 lines
2.1 KiB
Ruby
75 lines
2.1 KiB
Ruby
class Crm::CustomersController < ApplicationController
|
|
before_action :set_crm_customer, only: [:show, :edit, :update, :destroy]
|
|
|
|
# GET /crm/customers
|
|
# GET /crm/customers.json
|
|
def index
|
|
@crm_customers = Crm::Customer.all
|
|
end
|
|
|
|
# GET /crm/customers/1
|
|
# GET /crm/customers/1.json
|
|
def show
|
|
end
|
|
|
|
# GET /crm/customers/new
|
|
def new
|
|
@crm_customer = Crm::Customer.new
|
|
end
|
|
|
|
# GET /crm/customers/1/edit
|
|
def edit
|
|
end
|
|
|
|
# POST /crm/customers
|
|
# POST /crm/customers.json
|
|
def create
|
|
@crm_customer = Crm::Customer.new(crm_customer_params)
|
|
|
|
respond_to do |format|
|
|
if @crm_customer.save
|
|
format.html { redirect_to @crm_customer, notice: 'Customer was successfully created.' }
|
|
format.json { render :show, status: :created, location: @crm_customer }
|
|
else
|
|
format.html { render :new }
|
|
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# PATCH/PUT /crm/customers/1
|
|
# PATCH/PUT /crm/customers/1.json
|
|
def update
|
|
respond_to do |format|
|
|
if @crm_customer.update(crm_customer_params)
|
|
format.html { redirect_to @crm_customer, notice: 'Customer was successfully updated.' }
|
|
format.json { render :show, status: :ok, location: @crm_customer }
|
|
else
|
|
format.html { render :edit }
|
|
format.json { render json: @crm_customer.errors, status: :unprocessable_entity }
|
|
end
|
|
end
|
|
end
|
|
|
|
# DELETE /crm/customers/1
|
|
# DELETE /crm/customers/1.json
|
|
def destroy
|
|
@crm_customer.destroy
|
|
respond_to do |format|
|
|
format.html { redirect_to crm_customers_url, notice: 'Customer was successfully destroyed.' }
|
|
format.json { head :no_content }
|
|
end
|
|
end
|
|
|
|
private
|
|
# Use callbacks to share common setup or constraints between actions.
|
|
def set_crm_customer
|
|
@crm_customer = Crm::Customer.find(params[:id])
|
|
end
|
|
|
|
# Never trust parameters from the scary internet, only allow the white list through.
|
|
def crm_customer_params
|
|
params.require(:crm_customer).permit(:name, :company, :contact_no, :email, :date_of_birth, :membership_id, :membership_type, :membership_authentication_code)
|
|
end
|
|
end
|