class Admin::AdminsController < ApplicationController
  layout "admin"
  
  before_filter :auth_admin
  
  before_filter :is_super_admin
  
  def index
    
    @admins = Admin.all
  end


  def show
    @admin = Admin.find(params[:id])

  end


  def new
    @admin = Admin.new
  
  end

  def edit
    @admin = Admin.find(params[:id])
  
  end

  def create
    @admin = Admin.new(admin_params)
    
    if @admin.save
      @admins = Admin.all
          
    else
      render :action => "new" 
    end
  end

  def update
    @admin = Admin.find(params[:id])
    
    if @admin.update_attributes(admin_params)

          
    else
      render :action => "edit" 
    end
    
  end
      


  def destroy
    @admin = Admin.find(params[:id])
    
    @admin.destroy if @admin != @current_admin
  
  end
  
  private
      def admin_params
        params.require(:admin).permit!
      end



end
