kaps_app/app/controllers/public/kaps_controller.rb
Nicolas Bally d60301e8a7 initial
2019-01-21 01:15:10 +01:00

72 lines
1014 B
Ruby

# -*- encoding : utf-8 -*-
class Public::KapsController < ApplicationController
layout "public"
before_filter :auth_p_customer
def index
@kaps = current_p_customer.kaps.order(:name).all
end
def show
@kap = current_p_customer.kaps.find(params[:id])
end
def new
@kap = current_p_customer.kaps.new
end
def edit
@kap = current_p_customer.kaps.find(params[:id])
end
def create
@kap = current_p_customer.kaps.new(params.require(:kap).permit!)
if @kap.save
@kaps = current_p_customer.kaps.order(:name).all
else
render action: "new"
end
end
def update
@kap = current_p_customer.kaps.find(params[:id])
if @kap.update_attributes(params.require(:kap).permit!)
@kaps = current_p_customer.kaps.order(:name).all
else
render action: "edit"
end
end
def destroy
@kap = current_p_customer.kaps.find(params[:id])
@kap.destroy
end
end