lockaz_app/app/controllers/admin/p_commercials_controller.rb
Nicolas Bally f20fe482c6 initial
2020-04-06 10:38:07 +02:00

78 lines
1.1 KiB
Ruby

# -*- encoding : utf-8 -*-
class Admin::PCommercialsController < ApplicationController
layout "admin"
before_action :auth_admin
before_action :admin_space
def admin_space
@admin_space = "clients"
end
def index
@p_commercials = PCommercial.order(:name).all
end
def show
@p_commercial = PCommercial.find(params[:id])
end
def new
@p_commercial = PCommercial.new
end
def edit
@p_commercial = PCommercial.find(params[:id])
end
def create
@p_commercial = PCommercial.new(params.require(:p_commercial).permit!)
if @p_commercial.save
@p_commercials = PCommercial.order(:name).all
else
render action: "new"
end
end
def update
@p_commercial = PCommercial.find(params[:id])
if @p_commercial.update_attributes(params.require(:p_commercial).permit!)
@p_commercials = PCommercial.order(:name).all
else
render action: "edit"
end
end
def destroy
@p_commercial = PCommercial.find(params[:id])
@p_commercial.destroy
end
end