Skip to content

Commit 6464fc0

Browse files
committed
Merge pull request #232 from CyborgMaster/models-in-subdirectories
Don't crash on inherited models in subdirectories.
2 parents 46dc084 + dd28720 commit 6464fc0

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

lib/annotate/annotate_models.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -386,7 +386,8 @@ def get_model_class(file)
386386
get_loaded_model(model_path) or raise LoadError.new("cannot load a model from #{file}")
387387
rescue LoadError
388388
# this is for non-rails projects, which don't get Rails auto-require magic
389-
if Kernel.require(file)
389+
file_path = File.expand_path(file)
390+
if File.file?(file_path) && Kernel.require(file_path)
390391
retry
391392
elsif model_path.match(/\//)
392393
model_path = model_path.split('/')[1..-1].join('/').to_s

0 commit comments

Comments
 (0)