app/controllers/employees_controller.rb
def toggle_active
    referring_page = request.referer
    authorize! :destroy, @employee
    if @employee != @current_user
      if @employee.active
        @employee.active = false
        flash[:notice] = t(:employee) + "Deactivated"
      else
        @employee.active = true
        flash[:notice] = t(:employee) + "Activated"
      end
      @employee.save
    else
      flash[:error] = t(:cannot_delete_self)
    end
    unless referring_page.blank?
      redirect_to referring_page
    else
      redirect_to home_pages_path
    end
  end
# Sets the specified employee's 'active' field to false. Inactive no longer appear in lists for
# creating new associations, but all their existing associations are preserved.
Sets the specified employee's 'active' field to false. Inactive no longer appear in lists for
creating new associations, but all their existing associations are preserved.
Sets the specified employee ' s ' active ' field to false . Inactive no longer appear in lists for creating new associations but all their existing associations are preserved .
def toggle_active
    referring_page = request.referer
    authorize! :destroy, @employee
    if @employee != @current_user
      if @employee.active
        @employee.active = false
        flash[:notice] = t(:employee) + "Deactivated"
      else
        @employee.active = true
        flash[:notice] = t(:employee) + "Activated"
      end
      @employee.save
    else
      flash[:error] = t(:cannot_delete_self)
    end
    unless referring_page.blank?
      redirect_to referring_page
    else
      redirect_to home_pages_path
    end
  end
def toggle_active referring_page = request . referer authorize! :destroy , @employee if @employee != @current_user if @employee . active @employee . active = false flash [ :notice ] = t ( :employee ) + "Deactivated" else @employee . active = true flash [ :notice ] = t ( :employee ) + "Activated" end @employee . save else flash [ :error ] = t ( :cannot_delete_self ) end unless referring_page . blank? redirect_to referring_page else redirect_to home_pages_path end end
Sets the specified employee's 'active' field to false.
Sets the specified employee ' s ' active ' field to false .