mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Silence errors occurring when reloading classes
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@27 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
This commit is contained in:
parent
a682d20873
commit
ac3c8a54f8
5 changed files with 12 additions and 5 deletions
|
@ -25,6 +25,7 @@
|
||||||
$:.unshift(File.dirname(__FILE__))
|
$:.unshift(File.dirname(__FILE__))
|
||||||
|
|
||||||
require 'active_record/support/clean_logger'
|
require 'active_record/support/clean_logger'
|
||||||
|
require 'active_record/support/misc'
|
||||||
|
|
||||||
require 'active_record/base'
|
require 'active_record/base'
|
||||||
require 'active_record/observer'
|
require 'active_record/observer'
|
||||||
|
|
|
@ -562,7 +562,7 @@ module ActiveRecord
|
||||||
|
|
||||||
def require_association_class(class_name)
|
def require_association_class(class_name)
|
||||||
begin
|
begin
|
||||||
require(Inflector.underscore(class_name))
|
require_or_load(Inflector.underscore(class_name))
|
||||||
rescue LoadError
|
rescue LoadError
|
||||||
# Failed to load the associated class -- let's hope the developer is doing the requiring himself.
|
# Failed to load the associated class -- let's hope the developer is doing the requiring himself.
|
||||||
end
|
end
|
||||||
|
|
|
@ -549,7 +549,7 @@ module ActiveRecord #:nodoc:
|
||||||
def require_or_load(file_name)
|
def require_or_load(file_name)
|
||||||
if !associations_loaded.include?(file_name)
|
if !associations_loaded.include?(file_name)
|
||||||
associations_loaded << file_name
|
associations_loaded << file_name
|
||||||
reload_associations ? load("#{file_name}.rb") : require(file_name)
|
reload_associations ? silence_warnings { load("#{file_name}.rb") } : require(file_name)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
6
activerecord/lib/active_record/support/misc.rb
Normal file
6
activerecord/lib/active_record/support/misc.rb
Normal file
|
@ -0,0 +1,6 @@
|
||||||
|
def silence_warnings
|
||||||
|
old_verbose, $VERBOSE = $VERBOSE, nil
|
||||||
|
result = yield
|
||||||
|
$VERBOSE = old_verbose
|
||||||
|
return result
|
||||||
|
end
|
Loading…
Reference in a new issue