aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorDavid Heinemeier Hansson <david@loudthinking.com>2004-11-30 16:25:08 +0000
committerDavid Heinemeier Hansson <david@loudthinking.com>2004-11-30 16:25:08 +0000
commitac3c8a54f83418b5cac4b093fc1bae29f59f3a1f (patch)
tree74af81eee9a48c8f61f3aa3c3f462c05426f55d5 /activerecord
parenta682d20873ce0b36e2f1885b4ccc19cd8f45d5ed (diff)
downloadrails-ac3c8a54f83418b5cac4b093fc1bae29f59f3a1f.tar.gz
rails-ac3c8a54f83418b5cac4b093fc1bae29f59f3a1f.tar.bz2
rails-ac3c8a54f83418b5cac4b093fc1bae29f59f3a1f.zip
Silence errors occurring when reloading classes
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@27 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rwxr-xr-xactiverecord/lib/active_record.rb1
-rwxr-xr-xactiverecord/lib/active_record/associations.rb2
-rw-r--r--activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb4
-rwxr-xr-xactiverecord/lib/active_record/base.rb4
-rw-r--r--activerecord/lib/active_record/support/misc.rb6
5 files changed, 12 insertions, 5 deletions
diff --git a/activerecord/lib/active_record.rb b/activerecord/lib/active_record.rb
index 9ce79284cd..0d02dde13a 100755
--- a/activerecord/lib/active_record.rb
+++ b/activerecord/lib/active_record.rb
@@ -25,6 +25,7 @@
$:.unshift(File.dirname(__FILE__))
require 'active_record/support/clean_logger'
+require 'active_record/support/misc'
require 'active_record/base'
require 'active_record/observer'
diff --git a/activerecord/lib/active_record/associations.rb b/activerecord/lib/active_record/associations.rb
index 596542c9d6..6e9dd3ac47 100755
--- a/activerecord/lib/active_record/associations.rb
+++ b/activerecord/lib/active_record/associations.rb
@@ -562,7 +562,7 @@ module ActiveRecord
def require_association_class(class_name)
begin
- require(Inflector.underscore(class_name))
+ require_or_load(Inflector.underscore(class_name))
rescue LoadError
# Failed to load the associated class -- let's hope the developer is doing the requiring himself.
end
diff --git a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
index 946f238f21..fd36352deb 100644
--- a/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
+++ b/activerecord/lib/active_record/associations/has_and_belongs_to_many_association.rb
@@ -86,13 +86,13 @@ module ActiveRecord
end
def insert_record_with_join_attributes(record, join_attributes)
- attributes = { @association_class_primary_key_name => @owner.id, @association_foreign_key => record.id }.update(join_attributes)
+ attributes = { @association_class_primary_key_name => @owner.id, @association_foreign_key => record.id }.update(join_attributes)
sql =
"INSERT INTO #{@join_table} (#{@owner.send(:quoted_column_names, attributes).join(', ')}) " +
"VALUES (#{attributes.values.collect { |value| @owner.send(:quote, value) }.join(', ')})"
@owner.connection.execute(sql)
end
-
+
def delete_records(records)
if sql = @options[:delete_sql]
records.each { |record| @owner.connection.execute(sql) }
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 3312d41d06..7238f97067 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -549,7 +549,7 @@ module ActiveRecord #:nodoc:
def require_or_load(file_name)
if !associations_loaded.include?(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
@@ -1048,4 +1048,4 @@ module ActiveRecord #:nodoc:
string[0..3] == "--- "
end
end
-end
+end \ No newline at end of file
diff --git a/activerecord/lib/active_record/support/misc.rb b/activerecord/lib/active_record/support/misc.rb
new file mode 100644
index 0000000000..db842f6061
--- /dev/null
+++ b/activerecord/lib/active_record/support/misc.rb
@@ -0,0 +1,6 @@
+def silence_warnings
+ old_verbose, $VERBOSE = $VERBOSE, nil
+ result = yield
+ $VERBOSE = old_verbose
+ return result
+end