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

class Admin::PSpecValuesController < ApplicationController
  layout "admin"
  before_action :auth_admin

  before_action :admin_space
  
  def admin_space
    @admin_space = "default"
  end
  
  def index
    @p_spec_values = PSpecValue.all

    @p_spec_values = sort_by_sorting(@p_spec_values, "id DESC")
    respond_to do |format|
      format.html{
      
        params[:search][:per_page] = params[:search][:per_page] || 100
        per_page = params[:search][:per_page]
        page = (params[:page] and params[:page] != "") ? params[:page] : 1 
        @p_spec_values = @p_spec_values.page(page).per(per_page)
      
      }
    end
  end

  def show
    @p_spec_value = PSpecValue.find(params[:id])

  end

  def new
    @p_spec_value = PSpecValue.new
  
  end

  def edit
    @p_spec_value = PSpecValue.find(params[:id])
    
  end

  def create
    @p_spec_value = PSpecValue.new(params.require(:p_spec_value).permit!)

    if @p_spec_value.save
      
    else
      render action: "new"
 
    end

  end


  def update
    @p_spec_value = PSpecValue.find(params[:id])


    if @p_spec_value.update_attributes(params.require(:p_spec_value).permit!)
      
    else
     render action: "edit" 
      
    end
      
  end


  def destroy
    @p_spec_value = PSpecValue.find(params[:id])
    @p_spec_value.destroy
    
  end
end
