Commit 43847211 by cuong.tran

Ignore 'already initialized constant' warnings when models are in additional auto_load roots, #281

parent 0caccf14
......@@ -481,7 +481,7 @@ module AnnotateModels
rescue LoadError
# this is for non-rails projects, which don't get Rails auto-require magic
file_path = File.expand_path(file)
if File.file?(file_path) && Kernel.require(file_path)
if File.file?(file_path) && silence_warnings { Kernel.require(file_path) }
retry
elsif model_path.match(/\//)
model_path = model_path.split('/')[1..-1].join('/').to_s
......@@ -612,5 +612,13 @@ module AnnotateModels
return ([id] << rest_cols << timestamps << associations).flatten
end
# Ignore warnings for the duration of the block ()
def silence_warnings
old_verbose, $VERBOSE = $VERBOSE, nil
yield
ensure
$VERBOSE = old_verbose
end
end
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