/ Published in: Rails
Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
def search # Book.rebuild_index @page_title = 'Search books' return unless request.post? @books = Book.find_by_contents(params[:q]) if params[:q] # flash.now[:notice] = 'No results.' unless @books.size > 0 end