Commit 6464fc08 by Cuong Tran

Merge pull request #232 from CyborgMaster/models-in-subdirectories

Don't crash on inherited models in subdirectories.
parents 46dc0846 dd287205
...@@ -386,7 +386,8 @@ module AnnotateModels ...@@ -386,7 +386,8 @@ module AnnotateModels
get_loaded_model(model_path) or raise LoadError.new("cannot load a model from #{file}") get_loaded_model(model_path) or raise LoadError.new("cannot load a model from #{file}")
rescue LoadError rescue LoadError
# this is for non-rails projects, which don't get Rails auto-require magic # this is for non-rails projects, which don't get Rails auto-require magic
if Kernel.require(file) file_path = File.expand_path(file)
if File.file?(file_path) && Kernel.require(file_path)
retry retry
elsif model_path.match(/\//) elsif model_path.match(/\//)
model_path = model_path.split('/')[1..-1].join('/').to_s model_path = model_path.split('/')[1..-1].join('/').to_s
......
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