From 723f147cb905d56dd485c37792dd61c3191f8126 Mon Sep 17 00:00:00 2001 From: Nikitas Tampakis Date: Fri, 26 May 2017 17:09:50 -0400 Subject: [PATCH] allow range limit and advanced search to install without conflicts --- .../install_generator.rb | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/lib/generators/blacklight_advanced_search/install_generator.rb b/lib/generators/blacklight_advanced_search/install_generator.rb index cf22144..580b089 100644 --- a/lib/generators/blacklight_advanced_search/install_generator.rb +++ b/lib/generators/blacklight_advanced_search/install_generator.rb @@ -33,11 +33,25 @@ def configuration end def install_search_history_controller - copy_file "search_history_controller.rb", "app/controllers/search_history_controller.rb" + path = 'app/controllers/search_history_controller.rb' + if File.exist? path + inject_into_file path, after: /include Blacklight::SearchHistory.*$/ do + "\n helper BlacklightAdvancedSearch::RenderConstraintsOverride" + end + else + copy_file 'search_history_controller.rb', path + end end def install_saved_searches_controller - copy_file "saved_searches_controller.rb", "app/controllers/saved_searches_controller.rb" + path = 'app/controllers/saved_searches_controller.rb' + if File.exist? path + inject_into_file path, after: /include Blacklight::SavedSearches.*$/ do + "\n helper BlacklightAdvancedSearch::RenderConstraintsOverride" + end + else + copy_file 'saved_searches_controller.rb', path + end end def inject_routes