aboutsummaryrefslogtreecommitdiffstats
path: root/activerecord/lib/active_record/reflection.rb
diff options
context:
space:
mode:
authorMurray Steele <muz@h-lame.com>2009-12-28 14:13:33 +0100
committerEloy Duran <eloy.de.enige@gmail.com>2009-12-28 15:12:17 +0100
commitff508640e28914da2b546f6a8c9f215bab201b61 (patch)
treeae952ef0dad923d9e7b3e5b36e2d74ba9f20867b /activerecord/lib/active_record/reflection.rb
parent6a74ee7f4deea4a44520d3fcc9120e0bb848823f (diff)
downloadrails-ff508640e28914da2b546f6a8c9f215bab201b61.tar.gz
rails-ff508640e28914da2b546f6a8c9f215bab201b61.tar.bz2
rails-ff508640e28914da2b546f6a8c9f215bab201b61.zip
Make polymorphic_inverse_of in Reflection throw an InverseOfAssociationNotFoundError if the supplied class doesn't have the appropriate association. [#3520 state:resolved]
Signed-off-by: Eloy Duran <eloy.de.enige@gmail.com>
Diffstat (limited to 'activerecord/lib/active_record/reflection.rb')
-rw-r--r--activerecord/lib/active_record/reflection.rb10
1 files changed, 5 insertions, 5 deletions
diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb
index 72f7df32c7..b751c9ad68 100644
--- a/activerecord/lib/active_record/reflection.rb
+++ b/activerecord/lib/active_record/reflection.rb
@@ -239,16 +239,16 @@ module ActiveRecord
def inverse_of
if has_inverse?
@inverse_of ||= klass.reflect_on_association(options[:inverse_of])
- else
- nil
end
end
def polymorphic_inverse_of(associated_class)
if has_inverse?
- associated_class.reflect_on_association(options[:inverse_of])
- else
- nil
+ if inverse_relationship = associated_class.reflect_on_association(options[:inverse_of])
+ inverse_relationship
+ else
+ raise InverseOfAssociationNotFoundError.new(self, associated_class)
+ end
end
end