Skip to content

Commit

Permalink
Detect model classes so it's compatible with Rails 2 & 3
Browse files Browse the repository at this point in the history
  • Loading branch information
gabebw committed Dec 21, 2010
1 parent bdd843b commit 6f018c2
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/thinkingtank/tasks.rb
Expand Up @@ -52,8 +52,19 @@ def reindex_models
STDOUT.flush


Object.subclasses_of(ActiveRecord::Base).each do |klass|
reindex klass if klass.is_indexable?
subclasses = nil
if Object.respond_to?(:subclasses_of)
subclasses = Object.subclasses_of(ActiveRecord::Base)
elsif ActiveRecord::Base.respond_to?(:descendants)
subclasses = ActiveRecord::Base.descendants
else
STDERR.puts "Couldn't detect models to index."
end

unless subclasses.nil?
subclasses.each do |klass|
reindex klass if klass.is_indexable?
end
end
end

Expand Down

0 comments on commit 6f018c2

Please sign in to comment.