# -*- encoding : utf-8 -*-

class Admin::PProductSpecsController < ApplicationController
  layout "admin"
  before_action :auth_admin
  
  before_action :admin_space
  
  def admin_space
    @admin_space = "ventes"
  end
  


  def index
    @p_product_specs = PProductSpec.order(:code).all

   
  end

  def show
    @p_product_spec = PProductSpec.find(params[:id])

  end

  def new
    
    
		@p_product_spec = PProductSpec.new
    

  end

 

  def edit
  
    
    @p_product_spec = PProductSpec.find(params[:id])
  end

  def create
    @p_product_spec = PProductSpec.new(params.require(:p_product_spec).permit!)


    if @p_product_spec.save
     @p_product_specs = PProductSpec.order(:code).all
      
    else
      render action: "new"
 
    end

  end


  def update
    @p_product_spec = PProductSpec.find(params[:id])


    if @p_product_spec.update_attributes(params.require(:p_product_spec).permit!)
      
       @p_product_specs = PProductSpec.order(:code).all
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @p_product_spec = PProductSpec.find(params[:id])
    @p_product_spec.destroy
    
    
  end
end
