aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord
diff options
context:
space:
mode:
authorNicholas Seckar <nseckar@gmail.com>2006-03-28 01:48:59 +0000
committerNicholas Seckar <nseckar@gmail.com>2006-03-28 01:48:59 +0000
commitb55fc9e85aa79ca4c9ad1aef74b5d1a87aab87bb (patch)
tree393f3234d03b8550ba8b4ce7d3342974cb305294 /activerecord
parente7db36bd8e4b1ce47f6246a52690861bd4547a4b (diff)
downloadrails-b55fc9e85aa79ca4c9ad1aef74b5d1a87aab87bb.tar.gz
rails-b55fc9e85aa79ca4c9ad1aef74b5d1a87aab87bb.tar.bz2
rails-b55fc9e85aa79ca4c9ad1aef74b5d1a87aab87bb.zip
Replace 'rescue Object' with a finer grained rescue. Closes #4431
git-svn-id: http://svn-commit.rubyonrails.org/rails/trunk@4076 5ecf4fe2-1ee6-0310-87b1-e25e094e27de
Diffstat (limited to 'activerecord')
-rw-r--r--activerecord/CHANGELOG2
-rwxr-xr-xactiverecord/lib/active_record/base.rb7
2 files changed, 7 insertions, 2 deletions
diff --git a/activerecord/CHANGELOG b/activerecord/CHANGELOG
index f90ba96bd1..fd84c1052b 100644
--- a/activerecord/CHANGELOG
+++ b/activerecord/CHANGELOG
@@ -1,5 +1,7 @@
*SVN*
+* Replace 'rescue Object' with a finer grained rescue. Closes #4431. [Nicholas Seckar]
+
* Fixed eager loading so that an aliased table cannot clash with a has_and_belongs_to_many join table [Rick]
* Add support for :include to with_scope [andrew@redlinesoftware.com]
diff --git a/activerecord/lib/active_record/base.rb b/activerecord/lib/active_record/base.rb
index 62ea47226e..5b02d17f59 100755
--- a/activerecord/lib/active_record/base.rb
+++ b/activerecord/lib/active_record/base.rb
@@ -1232,9 +1232,12 @@ module ActiveRecord #:nodoc:
# Returns the class type of the record using the current module as a prefix. So descendents of
# MyApp::Business::Account would appear as MyApp::Business::AccountSubclass.
def compute_type(type_name)
+ modularized_name = type_name_with_module(type_name)
begin
- instance_eval(type_name_with_module(type_name))
- rescue Object
+ instance_eval(modularized_name)
+ rescue NameError => e
+ first_module = modularized_name.split("::").first
+ raise unless e.to_s.include? first_module
instance_eval(type_name)
end
end