Skip to content

Instantly share code, notes, and snippets.

@hale
Last active December 22, 2015 04:09
Show Gist options
  • Save hale/6415083 to your computer and use it in GitHub Desktop.
Save hale/6415083 to your computer and use it in GitHub Desktop.
Hacky fix for failing search reindex in Honolulu Answers; analysemodels rake task starts from scratch, drops the tables.
diff --git a/app/models/guide_step.rb b/app/models/guide_step.rb
index da18e96..f36f8fb 100644
--- a/app/models/guide_step.rb
+++ b/app/models/guide_step.rb
@@ -2,4 +2,10 @@ class GuideStep < ActiveRecord::Base
include TankerArticleDefaults
belongs_to :guide, :class_name => 'Guide', :foreign_key => 'article_id'
attr_accessible :article_id, :title, :content, :preview, :step
+
+ delegate :category, :tags, :keywords, :to => :guide
+
+ def content_md
+ content
+ end
end
diff --git a/lib/tanker_article_defaults.rb b/lib/tanker_article_defaults.rb
index 35de389..f1a26ff 100644
--- a/lib/tanker_article_defaults.rb
+++ b/lib/tanker_article_defaults.rb
@@ -2,8 +2,11 @@ module TankerArticleDefaults
def self.included(base)
base.send(:include, ::Tanker)
- index = 'hnlgovanswers-development'
- index = 'hnlgovanswers' if Rails.env === 'production'
+ index = case Rails.env
+ when 'production' then 'hnlgovanswers'
+ when 'staging' then 'hnlgovanswers-stage'
+ else 'hnlgovanswers-dev'
+ end
base.tankit index, :as => 'Article' do
indexes :title
diff --git a/lib/tasks/analyse_models.rake b/lib/tasks/analyse_models.rake
index d904843..191bf72 100644
--- a/lib/tasks/analyse_models.rake
+++ b/lib/tasks/analyse_models.rake
@@ -3,6 +3,8 @@ namespace :admin do
task :analysemodels => :environment do
pbar = ProgressBar.new("Please wait...", Article.count)
+ Keyword.destroy_all
+ Wordcount.destroy_all
Article.all.each do |article|
article.analyse_now
pbar.inc
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment