class Admin::StudentUsersController < ApplicationController
  layout "admin"
  
  before_filter :auth_admin
  
  def index
    
    @student_users = StudentUser.all
  end


  def show
    @student_user = StudentUser.find(params[:id])

  end


  def new
    @student_user = StudentUser.new
  
  end

  def edit
    @student_user = StudentUser.find(params[:id])
  
  end

  def create
  	@student_user = StudentUser.new(student_user_params)
    
    if @student_user.save
      redirect_to admin_student_users_path
  	else
  		render :action => "new" 
  	end
  end

  def update
  	@student_user = StudentUser.find(params[:id])
    
    if @student_user.update_attributes(student_user_params)

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


  def destroy
  	@student_user = StudentUser.find(params[:id])
	  
    @student_user.destroy if @student_user != @current_student_user
  
  end
  
  private
      def student_user_params
        params.require(:student_user).permit!
      end



end
