class Admin::StudentGroupsController < ApplicationController
  layout "admin"
  
  before_filter :auth_admin
  
  def index
    
    @student_groups = StudentGroup.all
  end


  def show
    @student_group = StudentGroup.find(params[:id])

  end


  def new
    @student_group = StudentGroup.new
  
  end

  def edit
    @student_group = StudentGroup.find(params[:id])
  
  end

  def create
  	@student_group = StudentGroup.new(student_group_params)
    
    if @student_group.save
      redirect_to admin_student_groups_path
  	else
  		render :action => "new" 
  	end
  end

  def update
  	@student_group = StudentGroup.find(params[:id])
    
    if @student_group.update_attributes(student_group_params)

          redirect_to admin_student_groups_path
  	else
  		render :action => "edit" 
  	end
    
  end
  		


  def destroy
  	@student_group = StudentGroup.find(params[:id])
	  
    @student_group.destroy if @student_group != @current_student_group
    render :layout => false
  end
  
  private
      def student_group_params
        params.require(:student_group).permit!
      end



end
