Commit 076e7786 by Alex Chaffee

Integrate various fixes around finding model classes, including…

Integrate various fixes around finding model classes, including https://github.com/ctran/annotate_models/pull/82 and https://github.com/ctran/annotate_models/pull/85
parent 75e4bfa8
......@@ -317,7 +317,11 @@ module AnnotateModels
# Retrieve loaded model class by path to the file where it's supposed to be defined.
def get_loaded_model(model_path)
ObjectSpace.each_object(::Class).
select { |c| c.ancestors.include?(ActiveRecord::Base) }.
select do |c|
Class === c and # note: we use === to avoid a bug in activesupport 2.3.14 OptionMerger vs. is_a?
c.ancestors.respond_to?(:include?) and # to fix FactoryGirl bug, see https://github.com/ctran/annotate_models/pull/82
c.ancestors.include?(ActiveRecord::Base)
end.
detect { |c| ActiveSupport::Inflector.underscore(c) == model_path }
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment