Class: HomeController

Inherits:
ApplicationController show all
Defined in:
app/controllers/home_controller.rb

Instance Method Summary collapse

Instance Method Details

#autocompleteObject


11
12
13
14
# File 'app/controllers/home_controller.rb', line 11

def autocomplete
  autocomplete_results = Book.search(params[:query], autocomplete: true, limit: 10).map(&:title)    
  render json: autocomplete_results
end

#indexObject


5
6
7
8
9
# File 'app/controllers/home_controller.rb', line 5

def index    
  @search_results = Book.search(params[:query], page: params[:page], per_page: 25, fields: [:title, :description]) if params[:query].present?
  @latest_books = Book.order(created_at: :desc).limit(6)   

end