search_controller.rb 342 Bytes
Newer Older
Zac Wood's avatar
Zac Wood committed
1 2
class SearchController < ApplicationController
  def index
Zac Wood's avatar
Zac Wood committed
3
    redirect_to(home_url) unless params[:query].length > 1
Zac Wood's avatar
Zac Wood committed
4

5 6 7
    results = SearchHelper::GenericItem.fetchall(String.new(params[:query]), semester: @semester).group_by(&:type)
    @instructors = results[:instructor]&.map(&:data)
    @courses = results[:course]&.map(&:data)
Zac Wood's avatar
Zac Wood committed
8 9
  end
end