Skip to content

Commit 076e778

Browse files
committed
Integrate various fixes around finding model classes, including #82 and #85
1 parent 75e4bfa commit 076e778

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

lib/annotate/annotate_models.rb

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,11 @@ def get_model_class(file)
317317
# Retrieve loaded model class by path to the file where it's supposed to be defined.
318318
def get_loaded_model(model_path)
319319
ObjectSpace.each_object(::Class).
320-
select { |c| c.ancestors.include?(ActiveRecord::Base) }.
320+
select do |c|
321+
Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
322+
c.ancestors.respond_to?(:include?) and # to fix FactoryGirl bug, see https://github.com/ctran/annotate_models/pull/82
323+
c.ancestors.include?(ActiveRecord::Base)
324+
end.
321325
detect { |c| ActiveSupport::Inflector.underscore(c) == model_path }
322326
end
323327

0 commit comments

Comments
 (0)