From 21ed08382807147cd0a956db59f2b240aaa2e60c Mon Sep 17 00:00:00 2001 From: enterteg Date: Mon, 28 Mar 2016 00:21:51 +0200 Subject: [PATCH] configured searchkick --- Gemfile | 3 +++ Gemfile.lock | 9 +++++++++ app/controllers/public_controller.rb | 1 + app/views/public/index.html.haml | 15 ++++++++++----- 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/Gemfile b/Gemfile index f4dd3d1..5bc06c5 100644 --- a/Gemfile +++ b/Gemfile @@ -37,6 +37,9 @@ gem 'truncate_html', '~> 0.9.3' gem 'lightbox2-rails' gem 'will_paginate', '~> 3.0.6' gem 'searchkick' +gem 'elasticsearch-model' +gem 'elasticsearch-rails' +gem 'bonsai-elasticsearch-rails' #------------------ # Use Capistrano for deployment # gem 'capistrano-rails', group: :development diff --git a/Gemfile.lock b/Gemfile.lock index fd8c280..4386b1a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -40,6 +40,7 @@ GEM bcrypt (3.1.11) binding_of_caller (0.7.2) debug_inspector (>= 0.0.1) + bonsai-elasticsearch-rails (0.0.4) builder (3.2.2) byebug (8.2.2) climate_control (0.0.3) @@ -62,6 +63,11 @@ GEM elasticsearch-transport (= 1.0.15) elasticsearch-api (1.0.15) multi_json + elasticsearch-model (0.1.8) + activesupport (> 3) + elasticsearch (> 0.4) + hashie + elasticsearch-rails (0.1.8) elasticsearch-transport (1.0.15) faraday multi_json @@ -186,9 +192,12 @@ PLATFORMS DEPENDENCIES bcrypt (~> 3.1.7) + bonsai-elasticsearch-rails byebug coffee-rails (~> 4.1.0) dropzonejs-rails + elasticsearch-model + elasticsearch-rails haml (~> 4.0, >= 4.0.7) jbuilder (~> 2.0) jquery-rails diff --git a/app/controllers/public_controller.rb b/app/controllers/public_controller.rb index 8960c72..c997e9b 100644 --- a/app/controllers/public_controller.rb +++ b/app/controllers/public_controller.rb @@ -33,6 +33,7 @@ def about def search if params[:search].present? @posts = Post.search(params[:search]) + @controller = 'search' else redirect_to action: :index end diff --git a/app/views/public/index.html.haml b/app/views/public/index.html.haml index 13818fe..002fab0 100644 --- a/app/views/public/index.html.haml +++ b/app/views/public/index.html.haml @@ -18,10 +18,15 @@ = "Food" =image_tag 'heart.png' -else - -if @posts.any? + - if @controller == 'search' + -if @posts.any? + .header= 'Found posts' + - else + .header= 'No posts found :(' + - else .header= 'Latest posts' - = render @posts + -if @posts + = render @posts - = will_paginate @posts, previous_label: 'prev', next_label: 'older posts', inner_window: 1, outer_window: 1 - - else - .header= 'No posts found :(' \ No newline at end of file + = will_paginate @posts, previous_label: 'prev', next_label: 'older posts', inner_window: 1, outer_window: 1 + \ No newline at end of file