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