class Admin::TCatsController < ApplicationController
  layout "admin"
  
  before_filter :auth_admin
  
  def index
    
    @t_cats = TCat.all
  end


  def show
    @t_cat = TCat.find(params[:id])

  end


  def new
    @t_cat = TCat.new
  
  end

  def edit
    @t_cat = TCat.find(params[:id])
  
  end

  def create
    @t_cat = TCat.new(t_cat_params)
    
    if @t_cat.save
      @t_cats = TCat.all
          
    else
      render :action => "new" 
    end
  end

  def update
    @t_cat = TCat.find(params[:id])
    
    if @t_cat.update_attributes(t_cat_params)

          
    else
      render :action => "edit" 
    end
    
  end
      


  def destroy
    @t_cat = TCat.find(params[:id])
    
    @t_cat.destroy
  
  end
  
  private
      def t_cat_params
        params.require(:t_cat).permit!
      end



end
