# -*- 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