app/controllers/application_controller.rb
# almost everything we do is restricted to a department so we always load_department
# feel free to skip_before_filter when desired
almost everything we do is restricted to a department so we always load_department
feel free to skip_before_filter when desired
almost everything we do is restricted to a department so we always load_department feel free to skip_before_filter when desired
def current_department
    unless @current_department
      if current_user
        @current_department = Department.where(session[:department_id]).first
        unless @current_department
          @current_department = current_user.default_department
          session[:department_id] = @current_department.id
        end
      end
    end
    @current_department
  end
def current_department unless @current_department if current_user @current_department = Department . where ( session [ :department_id ] ) . first unless @current_department @current_department = current_user . default_department session [ :department_id ] = @current_department . id end end end @current_department end
almost everything we do is restricted to a department so we always load_department
feel free to skip_before_filter when desired
almost everything we do is restricted to a department so we always load_department feel free to skip_before_filter when desired