From 9feadc11a71b655dd7748c0f3a92bc411c9e63c2 Mon Sep 17 00:00:00 2001 From: "Andrew S. Brown" Date: Mon, 26 May 2014 11:52:46 -0700 Subject: use name specified by 'as' for automatic inverse association to avoid reflecting on wrong association --- activerecord/lib/active_record/reflection.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'activerecord/lib/active_record') diff --git a/activerecord/lib/active_record/reflection.rb b/activerecord/lib/active_record/reflection.rb index 0eec6774a0..5a445eb892 100644 --- a/activerecord/lib/active_record/reflection.rb +++ b/activerecord/lib/active_record/reflection.rb @@ -433,7 +433,7 @@ Joining, Preloading and eager loading of these associations is deprecated and wi # returns either nil or the inverse association name that it finds. def automatic_inverse_of if can_find_inverse_of_automatically?(self) - inverse_name = ActiveSupport::Inflector.underscore(active_record.name).to_sym + inverse_name = ActiveSupport::Inflector.underscore(options[:as] || active_record.name).to_sym begin reflection = klass.reflect_on_association(inverse_name) -- cgit v1.2.3